我整整一周都在努力尝试使http重定向到https重定向,并使用弹性beantalk的nodejs的默认单实例设置,而不是在负载均衡器后面。我创建了一个.ebextensions / https-instance.config文件(如下所示)以成功设置https,并在顶部将端口80重定向,但无法识别。该网站仍允许使用http。
没有办法使用.ebextensions进行此重定向吗?我是否真的必须通过SSH进入服务器并获取现有的配置文件,然后覆盖整个内容,如下所示:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-proxy.html?
files:
/etc/nginx/conf.d/http_custom_proxy.conf:
mode: "000644"
owner: root
group: root
content: |
server {
listen 80;
return 301 https://$host$request_uri;
}
/etc/nginx/conf.d/https.conf:
...already working https code here
答案 0 :(得分:0)
尝试
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: ec2-user
group: ec2-user
content: |
TraceEnable off
RewriteEngine On
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>
答案 1 :(得分:-2)
对于https,您应该重定向到443端口。可能是问题