Luk*_*uke 9 reverse-proxy nginx amazon-web-services amazon-elb
在运行Nginx的EC2实例前面使用AWS Elastic Load Balancer(应用程序类型)时,我遇到了HTTPS请求的"502 Bad Gateway"问题.Nginx在服务于python应用程序(金字塔框架)的服务器服务器的每个实例上充当反向代理.我正在尝试在ELB上使用TLS终止,以便EC2实例仅处理HTTP.这是粗略的设置:
客户端HTTPS请求> ELB(侦听443,在后端转发到80)> Nginx侦听端口80(在Ec2实例上)>转发到waitress/Pyramid(在同一个ec2实例上)
当我在HTTPS上发出请求时,我收到502错误.但是,当我发出常规HTTP请求时,我会得到预期的响应(与上面相同的设置,除了ELB正在侦听端口80).
一些额外的信息:ELB健康检查正在运行.所有VPC /安全组都配置正确(我相信).我正在使用AWS上的标准设置/演练在ELB上使用AWS证书.我通过SSH进入Ec2实例和Nginx访问日志,看起来HTTPS请求仍然是加密的?还是一些编码问题?
这是EC2实例上的nginx.conf:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /etc/nginx/access.log;
sendfile on;
# Configuration containing list of application servers
upstream app_servers {
server 127.0.0.1:6543;
}
server {
listen 80;
server_name [MY-EC2-SERVER-NAME];
# Proxy connections to the application servers
# app_servers
location / {
proxy_pass http://app_servers;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
Run Code Online (Sandbox Code Playgroud)
Luk*_*uke 10
好吧,我想通了(我是个假人).我在ELB上设置了两个听众,一个用于80,一个用于443,这是正确的.正确设置80的侦听器以按预期通过HTTP转发到后端(Nginx)端口80.443监听器被错误地配置为通过HTTPS发送到后端的端口80.我更新了443监听器以使用与80监听器相同的规则(即监听443但通过HTTP发送到后端80)并且它有效.无视你们.
| 归档时间: |
|
| 查看次数: |
8770 次 |
| 最近记录: |