简体   繁体   English

Apache代理到Tomcat强制SSL

[英]Apache Proxy to Tomcat force SSL

My application is hosted in AWS. 我的应用程序托管在AWS中。 It has Apache proxying to tomcat. 它具有Apache代理tomcat。 SSL is terminated at the Elastic Load Balancer, and all traffic is offloaded to port 80. SSL在Elastic Load Balancer处终止,所有流量都卸载到端口80。

My need is to have all requests to the site be redirected to SSL. 我需要将对站点的所有请求都重定向到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. 我一直在大量阅读有关mod_rewrite的文章,并尝试了各种在Web上找到的解决方案,但未能完成这项工作。

To be clear, Apache is successfully proxying requests to Tomcat. 需要明确的是,Apache已成功将请求代理到Tomcat。 It's the redirection to HTTPS that I'm stuck on. 我坚持使用的是重定向到HTTPS。 Any suggestions would be welcome. 欢迎大家提出意见。

Try with the X-Forwarded-Proto header, eg: 尝试使用X-Forwarded-Proto标头,例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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