How to configure apahce as reverse proxy for tomcat7?


#1

Hello All, I have configured my tomcat7 to use SSL successfully on port 8443.
Now I want to accept for 443 port only I am using apache2 in front of it.
I added virtual host and this is the content:

ServerName example.com
ServerAlias *.example.com
ProxyPreserveHost on
ProxyRequests off

      <Proxy *>
              Order deny,allow
              Allow from all
       </Proxy>

SSLEngine on
SSLProxyEngine on
SSLVerifyClient None
SSLCertificateFile    /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/fullchain.pem



ProxyPass / http://localhost:8443/
ProxyPassReverse / http://localhost:8443/
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"

but I got this when I tried to connect to https://localhost

503 proxy Error the proxy server received an invalid response from an upstream server.

Also Should I configure certificate location for Apache also or just tomcat 7.
And How can I redirect any HTTP traffic to HTTPS.
Any help!


#2

https://localhost
doesn’t match
ServerName example.com
ServerAlias *.example.com
So without any extra “effort” you will not get the content you desire that way.
Try: https://example.com
you should see: http://localhost:8443 content

If the server_name is the same, then you only need one cert.
If they can both access the same cert location, once cert and one location should be fine.
You would only need an additional TLS connection for an additional listening port.
In this case 8443 is already TLS, if you also want 443 to serve TLS, then you need to go through those motions.

A quick online search will show several ways.


#3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.