I would like to ask how to set in the webserver, APACHE.
eg. like cPanel webmail, user only need to enter
http://www.example.com/webmail then it will match with http://www.example.com:2095/
I not sure it is set with .htaccess or set it at router level.
Can anyone advice how to do this?
It's called Reverse Proxy (even if you use it on the same server) : http://en.wikipedia.org/wiki/Reverse_Proxy
It can be done on Apache using standard modules mod_proxy and mod_rewrite. I have not done it myself on Apache, so I cannot tell if mod_rewrite will actually be required here ... but a lot of examples I have seen utilizing functionality of both of them.
There really a lot of examples around -- you should have no issues finding them. Start at the following links:
mod_proxy Apache manual
Using mod_rewrite for Proxying
Related
In my Play 2.4.x Web Application I am getting told by Google Analytics that I have two redundant hostnames namely
domain.net
www.domain.net
From an SEO standpoint it's important for me to fix this isse.
Normally this could be fixed with a .htaccess file doing a redirect from one of those two to the other one.
I want to know how I can achive the same solution using Play's application.conf file.
Reading the documentation I figured something like this could solve the issue:
%production%.application.baseUrl="http://domain.net/"
I am not sure though if this is enough.
What you want to do is create a filter that checks the incoming hostname, and if it's www.domain.net, redirect to domain.net. This would be equivalent to the Apache .htaccess. Of course, if you have a reverse proxy in front of Play (which you probably should, this is considered good practice) eg nginx or haproxy, then you can implement the redirect in there.
I have a site hosted in aws with www.domain.com with 2 sub domains test.domain.com and stage.domain.com. I am using MEAN for development, now what i want is to password protected my sub domains test.domain.com and stage.domain.com but in a similar fashion as we do in php using htaccess.
Now i personally like this htaccess approach because in this approach your code for the application will be same, authentication will be added by htaccess. Any idea how to do that in nodejs without altering application code, so that i can remove that in future if i want.
P.S. : Only hints are welcomed.
.htaccess does not alter the code because it's used by the Apache webserver.
Consider that Node.js IS your webserver, so that's where the magic happens (technically, it takes less code to add basicAuth to node than to add htaccess to apache + write the .htacess file).
Something, somewhere has to know that authentication is to be done :).
Here's the link to an easy way to do that in node :
Basic HTTP authentication with Node and Express 4
Is there a way to set multiple domains VirtualHosts with Google Pagespeed module?
I've tried this with ModPagespeedDomain with one domain of mine but not sure how to go about multiple ones I have about 14 on one server
I've also tried ModPagespeedMapOriginDomain but this doesn't seem to help either. I basically want combine_javascript and combine_css to work with all sites. I already have filters set up in the config file
ModPagespeed docs have a few examples for how to configure both server-wide and per VHost rewriters: https://developers.google.com/speed/pagespeed/module/configuration#virtual-hosts
You should be able to use ModPagespeedDomain to tell mod_pagespeed which domains to rewrite. Are basic rewrites like CSS minification and image re-compression working for you?
In order to get combine_* to work across multiple domains, you'll probably have to use ModPagespeedMapRewriteDomain to move them into one domain. Something like:
ModPagespeedMapRewriteDomain one.domain.com/shard1/ shard1.domain.com
ModPagespeedMapRewriteDomain one.domain.com/shard2/ shard2.domain.com
ModPagespeedMapRewriteDomain one.domain.com/shard3/ shard3.domain.com
ModPagespeedMapRewriteDomain one.domain.com/shard4/ shard4.domain.com
...
Then all rewritten resources from shard*.domain.com will be rewritten into one.domain.com.
Please read the documentation carefully, there are some assumptions that need to be satisfied for this directive.
I want to redirect all the users who enters www.siteA.com/folder1 to www.siteB.com/folder. But user should see www.siteA.com/folder1 in address bas even after redirection to www.siteB.com.
I do not know how to do it with .htaccess Can somebody please help me how to mask the url. I really need your help.
Thanks
You can "Force the substitution URL to be internally sent as a proxy request" via the P flag.
RewriteRule ^folder1(.*) http://www.siteB.com/folder$1 [P]
There are some other examples in the documentation of the RewriteRule.
If this does not work (e.g. no access to the server configuration and the proxy module is disabled) you are probably best of using a Proxy script like PHProxy.
On a second look I think PHProxy is not really what you need. Maybe give this one a try: http://code.google.com/p/php-proxy/ - The installation instructions look pretty simple.
You want to use proxying . On Apache, mod_proxy should do what you are looking for.
Bear in mind that your server will eat up twice the amount of bandwidth. Once to get the data from the source server and again to send it to the client.
i have a site like twitter.com on server one and on server two i have forum, which path is like domain.com/forum
on server one i wanted to implement wild card dns and put main domain on it. but on server two i wanted to keep forum separate, i cant give sub-domain forum.domain.com, because all its links are already put in search engines and link back to domain.com/forum.
so i was wondering, how can i put domain and wild card dns on server one and still able to give path on server 2 for domain.com/forum (as sub-folder).
any ideas?
do you think htaccess can do that job? if yes, then how?
You could use htaccess and mod_rewrite so domain.com/forum actually displays pages from forum.domain.com.
Maybe something like this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule domain.com/forum/(.+) forum.domain.com/$1
Easy - use a proxy! If you like apache you will love apache mod_proxy for your purpose.
<VirtualHost *:80>
ServerName maindomain.com
ServerAlias *.maindomain.com
# insert document root and general settings for this domain here
# ...
ProxyPass /forum http://forumdomain.com
ProxyPassReverse /forum http://forumdomain.com
ProxyPassReverseCookieDomain forumdomain.com maindomain.com
</VirtualHost>
This configuration makes apache do a HTTP-request to your internal domain (forumdomain.com) without notifiying the users browser of the internal location. Your Forum will be accessable at http://*.yourdomain.com/forum. Cookies and headers the forum sents will get rewritten accordingly and Search-engines will not take notice of your backend-server.
You can read more about it at http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Should you need to rewrite reference sin your html (href, src ...) you might google on "mod_proxy_html".
A solution like this could of course be build with other intelligent proxyservers like squid as well. You can use it to map any content from "backend servers" to your public domain.
Make sure routing is OK or set up a host-entry for your internal domain (forumdomain) with a internet ip-addresse 192.168 ...
Enjoy your site and give feedback how worked out :)
p.s.: a "RewriteRule" directive can potentially do the same thing for you but the rdirect will be visible (and executed) by the client unless you specify the "P", foricng it to do an internal proxy request. If available I would prefer the mod_proxy though as it is more versatile and allows for more configuration.
If you use a proxy on server 1 pointing to server2, you will increase the load on server 1, since all traffic will be routed through it. Besides, if server 1 goes down, nobody will be able to reach server 2 either. Of course it is possible though, but these things are to be considered.
I would suggest setting up a supdomain for server 2 anyway, like forum.domain.com, and on server 1 you set up a 301 redirect from domain.com/forum to forum.domain.com using mod_rewrite from htaccess. Using that technique, you can even redirect calls to specific links to their corresponding page on server 2. Search engines will follow the 301 and they will eventually update the index.
You can use a 301 redirect to make sure the search engine update their index with your new urls like so:
RewriteRule domain.com/forum/(.*) http://forum.domain.com/$1 [R=301,L]
If you've got two servers you don't really have much choice but to use a redirect (ideally a 301 Permanent redirect) to move users from domain.com/forum to forum.domain.com.
The only other way to do it would be to put a reverse proxy in front of those two servers, which reads the URL and internally directs the query to the right server, but that's then an extra piece of hardware.