Apache HTTP Proxying on non-default Ports
I’ve started proxying certain services through Apache to be able to have them on different machines than the main site/service.
Unfortunately I get tripped up every time I have to redo the proxy setup so here is the run down:
1.) Enable the mod: a2enmod proxy_http
2.) Add the services to ports.conf:
NameVirtualHost *:8090
NameVirtualHost *:8443
Listen 8090
#SSL port
Listen 8443
3.) Allow proxying in mods-enabled/proxy.conf:
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
#Allow from .example.com
</Proxy>
4.) Finally set it up in the virtual host config:
<VirtualHost *:8443>
ServerName mysite.com
ServerAlias *.mysite.com
ProxyRequests off
ProxyPass / http://ip.to.some.machine:8090/
ProxyPassReverse / http://ip.to.some.machine:8090/
SSLEngine on
SSLCertificateFile /etc/ssl/certs/main_cert.crt
SSLCertificateKeyFile /etc/ssl/private/mysite.key
SSLCACertificateFile /etc/ssl/certs/mysite_inter.crt
</VirtualHost>
<VirtualHost *:8090>
ServerName mysite.com
ServerAlias *.mysite.com
ProxyRequests off
ProxyPass / http://ip.to.some.machine:8090/
ProxyPassReverse / http://ip.to.some.machine:8090/
</VirtualHost>
5.) Open up ports 8090 and 8443 in IP Tables and restart Apache.