gpt4 book ai didi

ssl - SSL 上的 Nginx (443)

转载 作者:太空宇宙 更新时间:2023-11-03 13:09:19 25 4
gpt4 key购买 nike

我的目标是从端口 80 重定向到 443(强制 https),但无法首先获得有效的 https 配置。我收到 503 服务器错误,日志中没有任何内容。我查看了 SO 和 SF 上的所有帖子,没有一个有效(X_FORWARDED_PROTO、X-Forwarded-For header 没有区别。)。我在负载均衡器后面的 EC2 上,所以我不需要使用与 SSL 相关的指令,因为我已经在 ELB 上配置了我的证书。我正在使用 Tornado 作为网络服务器。

这是配置,如果有人有想法,谢谢!

http {
# Tornado server
upstream frontends {
server 127.0.0.1:8002;
}

server {
listen 443;

client_max_body_size 50M;

root <redacted>/static;

location ^~/static/ {
root <redacted>/current;
if ($query_string) {
expires max;
}
}

location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends;
}
}
}

最佳答案

嗯,有两个不同的任务:

如果您需要将所有 http 流量重定向到 https,则需要在 nginx 中创建 http 服务器:

    server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}

第二个注意,如果您的 SSL 在 ELB 处终止,那么您根本不需要启用 ssl 的 nginx 服务器。只需将流量从 ELB 传递到您的服务器 80 端口即可。

关于ssl - SSL 上的 Nginx (443),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13576319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com