【发布时间】:2018-07-04 13:39:25
【问题描述】:
我需要将 http 重定向到 https,我正在使用 Nginx 来做到这一点
我使用带有 ACM 推荐证书的负载均衡器。在路由 53 Ipv4 中使用
尝试从 /etc/nginx/sites-available/default 中的以下代码将 http 重定向到 https
server {
listen 80;
server_name mysite.com www.mysite.com;
location / {
if ($http_x_forwarded_proto != 'https') {
rewrite ^ https://$host$request_uri? permanent;
}
proxy_pass http://172.x1.x5.xx6:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
}
我面临的问题是公共 ipv4(公共 IP)也被重定向到 https 并且无法访问我的域
如何不重定向 ipv4(公共 IP)
【问题讨论】:
-
nginx中是否只有一个 server_name 设置? -
是的..我需要2个
标签: node.js amazon-web-services nginx amazon-route53 elastic-load-balancer