0

im running tomcat on my linux server and i want use a reverse proxy for this. After reading the manual in apacha for mod_proxy , i didnt really understand the /path in the proxypass .

i make a small example. the directory for my tomcat is /tomcat/webapp. Is then this following configuration right ?:

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ProxyRequests Off
ProxyPass /tomcat/webapp         http://127.0.0.1:8080
ProxyPassReverse /tomcat/webapp  http://127.0.0.1:8080
</VirtualHost> 

i would be thankful, im somebody with experience can help me out.

1 Answers1

2

Theoretically whichever ProxyPass directive you choose, it will work, even if you choose to proxy http://example.com:8080/webapp/ as http://example.com/foo/bar/baz/.

However, if your application uses absolute paths in hyperlinks, it is better to use the same URI path on both Apache and Tomcat or you will have problems like in this question. So:

  • if your application is well written, choose your favourite URL and adjust the webapp deployment on Tomcat to fit it.
  • if your application is badly written (e.g. has some hardcoded paths like in this question adjust the Apache path to fit the hardcoded deployment path.

Either way you should use:

ProxyPass "/path/to/webapp/" "http://127.0.0.1:8080/path/to/webapp/"

PS: Since apparently you want to run Tomcat on two ports, it is better if you tell the webapp that it is being proxied and that port 8443 is accessed through SSL:

<Connector port="8080"
           proxyName="example.com"
           proxyPort="80"
           redirectPort="443" />
<Connector port="8443"
           proxyName="example.com"
           proxyPort="443"
           scheme="https" secure="true" />

so the webapp will not generate useless redirects from port 8443 to port 443.