Mar*_*tor 6 apache https amazon-ec2 amazon-web-services amazon-elb
这是我的配置文件
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Redirect permanent / https://www.mywebsite.co/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Run Code Online (Sandbox Code Playgroud)
当我输入浏览器mywebsite.co时,它成功地重定向了我https://mywebsite.co但是由于此错误(谷歌浏览器),内容不会在页面上呈现
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
Run Code Online (Sandbox Code Playgroud)
我有一个使用端口80来处理http请求的EC2实例和一个处理https请求的负载均衡器.我不知道该怎么办,我在网上找到的解决方案都没有.
小智 12
当你点击ELB时,你通过端口443通过SSL请求,但是你要求后端作为不安全的端口80.这很好,但是你的配置不知道这应该超过443因为你是反向的代理它.对于Web服务器,这只是一个端口80不安全的请求,因此它将尝试重定向到SSL端口443,这就是它循环的原因.
您可以查看重写以分析转发的标头,而不是进行重定向,例如:
RewriteEngine On
RewriteCond %{HTTP:X-FORWARDED-PORT} !=443
RewriteRule ^(.*)$ https://www.mywebsite.co$1 [R=301,NE,L]
Run Code Online (Sandbox Code Playgroud)