简体   繁体   中英

Apache Proxy to Tomcat force SSL

My application is hosted in AWS. It has Apache proxying to tomcat. SSL is terminated at the Elastic Load Balancer, and all traffic is offloaded to port 80.

My need is to have all requests to the site be redirected to SSL. I've been doing a lot of reading about mod_rewrite and have experimented with various solutions I've found on the web, but have not been able to make this work.

To be clear, Apache is successfully proxying requests to Tomcat. It's the redirection to HTTPS that I'm stuck on. Any suggestions would be welcome.

Try with the X-Forwarded-Proto header, eg:

<VirtualHost *:80>
    ...
    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=permanent]
    ...
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM