I understand that to redirect from port 80 to port 8080 I can use the Apache module mod_proxy,
I understand that I have to change "something" to be like this (example from http://httpd.apache.org/docs/2.2/mod/mod_proxy.html):
ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar
What I don't understand is how do I "edit mod_proxy". I found a file called mod_proxy.so
but it is not a text file that can be edited.
What do I have to do to make these changes, is it a text file somewhere I have to edit or some commands I have to run?
EDIT:
Based on this question How to use mod_proxy to let my index of Apache go to Tomcat ROOT and be able to browse my other Apache sites
I edited httpd.conf to look like this:
LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#Enabling proxy for redirection to tomcat
#ProxyRequests Off
#ProxyPreserverHost On
<Proxy *>
Order deny, allow
Allow from all
</Proxy>
#ProxyPass / ajp://localhost:8009/
#ProxyPassReverse / ajp://localhost:8009/
<Location http://www.mywebserver.com>
Order allow,deny
Allow from all
PassProxy / http://localhost:8080/
PassReverseProxy / http://localhost:8080
</Location>
I then tried to restart apache with apachectl -k graceful
but I got:
Syntax error on line 207 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/httpd.conf: Cannot load /etc/apache2/modules/mod_proxy.so into server: /etc/apache2/modules/mod_proxy.so: cannot open shared object file: No such file or directory
Action '-k graceful' failed.
Any info on what I'm doing wrong or what I can read to get more info, would be much appreciated.
What I normally do is first enable
mod_proxy
andmod_proxy_ajp
. Depending on your distribution youa2enmod mod_proxy_ajp
and it enables them both as ajp depends onmod_proxy
.Then I add something like this:
This part is placed inside my
<VirtualHost>
. The rest is basic configuration set by the OS (just like your configuration shows, withProxyRequests Off
etc.)UPDATE: What you need to change, or at least verify is your tomcat server.xml. It must have the ajp-container enabled like this:
You can disable the connector on 8080 if that is all you serve from tomcat and if you do not need the backend. In case you don't have access to this, or ports for ajp are disabled, you can basically achieve the same wirth
8080
. Just replace the ajp:// tag in the provided configuration with http:// and add :8080 after IP-or-FQDN.UPDATE 2 To serve
/
just writeEnsure you comment out the
DocumentRoot /path/to/old/documentroot/
directive and the<Directory /path/to/old/documentroot/>
in your apache configuration.