我的目标是从端口80重定向到443(强制https),但无法首先获得有效的https配置.我收到503服务器错误,日志中没有任何内容.我查看了SO和SF上的所有帖子,它们都没有用(X_FORWARDED_PROTO,X-Forwarded-For标题没有区别.).我在负载均衡器后面的EC2上,因此我不需要使用与SSL相关的指令,因为我已经在ELB上配置了我的证书.我正在使用Tornado作为Web服务器.
这是配置,如果有人有想法,谢谢!
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 6
嗯,有两个不同的任务:
如果您需要将所有http流量重定向到https,则需要在nginx中创建http服务器:
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
Run Code Online (Sandbox Code Playgroud)
请注意,如果您的SSL在ELB终止,则根本不需要启用ssl的nginx服务器.只需将流量从ELB传递到服务器80端口即可.
| 归档时间: |
|
| 查看次数: |
1716 次 |
| 最近记录: |