Nginx https反向代理在Amazon EC2中设置

我在Amazon EC2上运行Ubuntu 14.04.3和Nginx 1.4.6。 我试图在8000端口上为我的应用程序设置一个反向代理,当我访问www.mywebsite.com:8000时,我可以看到它正在运行。 反向代理应将所有httpstream量redirect到https,然后为该应用程序提供服务。

这是我的网站启用configuration:

server { listen 80; server_name mywebsite.com return 301 https://$host$request_uri; } server { listen 443 ssl; server_name mywebsite.com access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ssl on; ssl_certificate /etc/nginx/ssl/certificate.crt; ssl_certificate_key /etc/nginx/ssl/key.key; keepalive_timeout 60; ssl_ciphers HIGH:!ADH:!MD5; ssl_protocols TLSv1; ssl_prefer_server_ciphers on; proxy_buffers 16 64k; proxy_buffer_size 128k; location / { proxy_pass http://IPADDRESS:8000; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_read_timeout 60m; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Front-End-Https On; } } 

起初我使用localhost作为我的IPAddress,但在阅读了这个暗示使用ec2的私有IP而不是公众的问题之后,我也尝试了这个。 但没有雪茄。

我有一个打开的terminal被打入我的应用程序,所以我可以看到一个http请求何时进入,当我访问mywebsite.com:8000时,它做了什么。 然而www.mywebsite.com是一个空白页面,最终得到一个时间,我的应用程序显示它没有收到最初的请求。 Nginx是在80和443端口上监听的唯一应用程序。

我的错误和访问日志也是空的。 任何人都可以看到发生了什么?

更新

Nginx正在监听端口80,但是连接被拒绝的cURL尝试返回,结果我的iptables的默认设置被改变了。 将这些返回到默认允许的stream量来击中Nginx。

 iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT 

有趣的是,使用Ec2的私有IP地址代理时没有必要,因为localhost工作正常。