[英]Cannot Redirect HTTP to HTTPS with EB Single Instance NodeJS NGINX Config
我整周都在努力尝试使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
尝试
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>
对于https,您应该重定向到443端口。 那可能是问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.