【问题标题】:Java app running on Amazon EC2 - redirect http to https在 Amazon EC2 上运行的 Java 应用程序 - 将 http 重定向到 https
【发布时间】:2014-05-08 22:02:52
【问题描述】:

我最近开始使用 Amazon AWS 来托管我的网站。我为网站安装了自签名 ssl 证书,它工作正常。我还看到为在此 Amazon EC2 服务器上运行的单个网站创建的正确虚拟主机。我想将所有 http 流量重定向到 https,为此我添加了: 永久重定向/https://mywebsite.com/,但我的网站仍未重定向到 https。我还需要做些什么来完成这项工作吗? 仅供参考 - 我没有使用负载平衡,现在也不打算使用。

【问题讨论】:

  • 你在哪里添加了重定向?您可以将 Apache 配置文件的 VirtualHost 部分添加到您的帖子中吗?
  • :80> ServerName mywebsite.com ServerAlias root DocumentRoot /srv/www/root/current/ 选项 FollowSymLinks AllowOverride All Order allow ,deny Deny from all RewriteEngine On Include /etc/httpd/sites-available/root.conf.d/rewrite RewriteLog /var/log/httpd/root-rewrite.log RewriteLogLevel 0 Include /etc /httpd/sites-available/root.conf.d/local* ProxyPass / localhost:8080 ProxyPassReverse / localhost:8080 永久重定向 / mywebsite.com
  • :443> ServerName mywebsite.com ServerAlias root DocumentRoot /srv/www/root/current/ SSLEngine on SSLProxyEngine on SSLCertificateFile /etc/httpd/ssl/mywebsite.crt SSLCertificateKeyFile /etc /httpd/ssl/mywebsite.key SetEnvIf User-Agent ".*MSIE." nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0 RewriteEngine On Include /etc/httpd/sites-available/root。 conf.d/rewrite-ssl* RewriteLog /var/log/httpd/root-rewrite.log RewriteLogLevel 0 ProxyPass / localhost:8080 ProxyPassReverse / localhost:8080
  • 网站不允许我发布更大的 cmets。将我的 VH 信息分为 2 条消息。请查看第一篇文章的最后一行以查看我正在做的永久重定向。谢谢
  • @user3616677 您应该将其编辑到您的问题中,而不是将其放入 cmets...

标签: ssl amazon-ec2


【解决方案1】:

您的重定向应包含 https 协议部分。试试这个:

Redirect permanent / https://mywebsite.com 

【讨论】:

  • 维克多,我已将其添加到 vh:80。请看我的第一条评论。由于某种原因,https 被从评论中删除。
  • 你重启你的apache服务器了吗?
  • 是的,我做到了。谢谢
  • 我看到如果 URL 的末尾没有 /。这有什么区别吗?
  • 不,它应该与最后的斜线一起使用。你的 apache 错误日志记录了什么吗?
猜你喜欢
  • 2012-10-24
  • 2016-03-11
  • 2023-03-28
  • 2018-05-12
  • 2015-12-26
  • 2014-07-17
  • 1970-01-01
  • 1970-01-01
  • 2020-09-03
相关资源
最近更新 更多