1
votes

I am using Apache Tomcat for deploying the application.The application require ProxyPass and ProxyPassReverse to be configured,I have read documents stating that the ProxyPass are served by Apache Server.How can I serve and configure the same using tomcat without using Apache Server.

I have read the below codeis configured in httpd.conf file of Apache server for serving proxyPass and ProxyPassreverse:

NameVirtualHost *:80
<VirtualHost *:80>
     ServerName 127.0.0.1
     DocumentRoot /var/www

     ProxyRequests Off
     ProxyPreserveHost On

     ProxyPass /static/ !
     ProxyPass / ajp://localhost:8009/
     ProxyPassReverse / ajp://localhost:8009/

.
.
.
     Alias /static/ "/apache/www/"

</VirtualHost>
1

1 Answers

1
votes

These directives are used if you have a reverse proxy "in front" of tomcat. In this case, if the reverse proxy is Apache httpd. The directives are required because tomcat might not know the original request's target, and httpd can "translate" from what tomcat thinks the request should look like to what the user's browser needs the request to be.

If you do not have a reverse proxy in the game, Tomcat would see the original request data, and all of these instructions can simply be omitted.

If you are using a different reverse proxy (say nginx) you'll need to find the equivalent instructions that make the reverse proxy of your choice adapt both worlds to each other.

Another message of caution: If you're handling everything on Tomcat, make sure you're not running as root just in order to bind to ports 80 or 443. You must not run tomcat as root! (If you don't: Good. I've put it here for everybody who reads it. Can't be repeated often enough)