Installing a reverse proxy using apache - tooltwist/documentation GitHub Wiki
#Installing a reverse proxy using Apache
(on a Linux machine)
Ensure that port 80 is free on the server. If you had installed anything else before, disable it, or ensure iptables, the Linux firewall is free for port 80 and no forwarding items are there.
###Install Apache
Use this command
yum install httpd
to install apache
###Ensure Apache is on the system startup
Check using this command to see if Apache is there on system startup
chkconfig --list | grep httpd
If everything is marked off, then use this command to turn Apache on for runlevels 2, 3 and 5.
chkconfig --level 235 httpd on
Use this command to ensure Apache is started
service httpd start
###Setup reverse proxy config in Apache
Edit this file /etc/httpd/httpd.conf
and ensure that all "forward" proxy configurations are commented out. This happens to be the default if you install Apache, but it always helps to ensure.
Towards the end of the file, add the following lines to the httpd.conf
file.
NameVirtualHost *
<VirtualHost *>
ServerName domain.example.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
In the above file, domain.example.com
is the incoming domain, and localhost:8080
is the target where the reverse proxy should go to.
Once finished, restart Apache using the service httpd restart
command.
###Troubleshooting reverse proxy configs
Ensure that your Apache config is ok. Verify using the command apachectl configtest
.
Ensure selinux is either permissive or disabled. If not either, it should be setup to allow port access to the target port for http. Use the sestatus
command to check selinux status.
Always look at the Apache log files in /var/logs/httpd
to check.