: Serve most of a domain with Apache, but use mod_proxy to serve some URLs from Lighttpd So we wish to host some pages on a new server with apache2, and embed some of our old content &
So we wish to host some pages on a new server with apache2, and embed some of our old content & functionality from another server with lighttpd in an iframe. I'm looking at this configuration from the apache docs (http://httpd.apache.org/docs/2.2/vhosts/examples.html#page-header) under "Using Virtual_host and mod_proxy" together.
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / 192.168.111.2/ ProxyPassReverse / 192.168.111.2/ ServerName hostname.example.com
</VirtualHost>
The only issue is that I want to proxy only on a subdomain, or even better, if I can keep the top domain and proxy only if the url contains a particular path ie. "/myprocess.php". So in essence the DNS will point to the apache2 as the "master router".
More posts by @Turnbaugh106
2 Comments
Sorted by latest first Latest Oldest Best
You're probably best doing this using a setup of 3 VirtualHost declarations.
The first, becomes a default catch-all for any name that has not been specified, and you could have an index.php in the /var/www/default/ that either returns a blank page or an HTTP 404 response etc:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName hostname.example.com
DocumentRoot /var/www/default
DirectoryIndex index.php index.html index.htm
ErrorLog /var/log/httpd/default/error_log
TransferLog /var/log/httpd/default/access_log
</VirtualHost>
The second, becomes your main new website using the domain example.com:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com DocumentRoot /var/www/default
DirectoryIndex index.php index.html index.htm
ErrorLog /var/log/httpd/newsite/error_log
TransferLog /var/log/httpd/newsite/access_log
</VirtualHost>
The third, works as a proxy to your old website using the subdomain oldsite.example.com:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName oldsite.example.com
ProxyPreserveHost On
ProxyPass / 192.168.111.2/ ProxyPassReverse / 192.168.111.2/ ErrorLog /var/log/httpd/oldsite/error_log
TransferLog /var/log/httpd/oldsite/access_log
</VirtualHost>
You can use mod_rewrite to set rules about which URLs should be served via reverse proxy. There is documentation about it on the Apache website: httpd.apache.org/docs/2.2/rewrite/proxy.html
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.