Reputation: 170
So, I have two servers, let's call them nice#server and a#another#server
nice#server is what clients will talk to and is running Apache2 performing basic reverse proxy for simple services, a#another#server hosts a proprietary application server on port . I need to completely rewrite two url's before they get passed through, but just add a folder to all other URLs.
Some Examples below:
User Requests: nice#server/
Apache requests a#another#server:8080/appname
User Requests: nice#server/css#css
Apache requests a#another#server:8080/appname/css#css
User Requests: nice#server/a
Apache requests a#another#server:8080/appname/command1?name=option1
User Requests: nice#server/b
Apache requests a#another#server:8080/appname/app2?name=option2
I have done a lot of Googling and test on this but cannot seem to get it to work, sorry I've not kept the links that i've tried!!! I have stripped the vHost file right back down for now.
<VirtualHost *:80>
ServerName service#domain#com
ErrorLog ${APACHE_LOG_DIR}/service-domain-com-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/service-domain-com-access.log combined
ProxyPreserveHost On
ProxyRequests off
ProxyPass / a#another#server:8080/
ProxyPassReverse / a#another#server:8080/
</VirtualHost>
Thanks in advance for any guidance on how to do this.
Upvotes: 1
Views: 54
Reputation: 170
I managed to get this fixed with a bit of trial and error. posting solution here in case anyone else is having the issue.
<VirtualHost *:80>
ServerName service.domain.com
ErrorLog ${APACHE_LOG_DIR}/internal-fqdn-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/internal-fqdn-access.log combined
RewriteEngine On
RewriteRule ^/a$ /appname/command1?name=option1 [PT]
ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://a.another.server:8080/
ProxyPassReverse / http://a.another.server:8080/
</VirtualHost>
Upvotes: 1