【发布时间】:2015-01-22 07:46:36
【问题描述】:
目前,我正在使用 AWS Ubuntu EC2 实例,在端口 3000 上运行 Node.js 应用程序,该应用程序具有 Nginx 反向代理。我一直在尝试启用 HTTPS 并添加 SSL 证书,并且我已经成功,因为我在 nginx.conf 文件中没有收到任何错误。但是,我将我的主网站“example.com”重定向到 AWS 服务器的公共 DNS,当我尝试加载“http://example.com”或“https://example.com”页面时,我收到“无法连接”来自 Firefox 的错误,这是我的测试浏览器。此外,当我运行sudo nginx -t 时,配置文件中没有语法错误,当我检查/var/log/nginx/error.log 文件时,它是空的。下面是我当前的 nginx.conf 文件。
更新:我将 server_name 从 example.com 更改为我服务器的公共 DNS,我们称之为 amazonaws.com。现在,当我输入https://amazonaws.com 时,页面加载并在通过 ssllabs.com 运行网站时显示 SSL 证书。但是,当我输入 amazonaws.com 或 http://amazonaws.com 时,我会像以前一样得到一个空白页。
user root;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
# max_clients = worker_processes * worker_connections / 4
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
# backend applications
upstream nodes {
server 127.0.0.1:3000;
keepalive 64;
}
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/example_com.crt;
ssl_certificate_key /etc/nginx/ssl/example_com.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name example.com;
# everything else goes to backend node apps
location / {
proxy_pass http://nodes;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
}
}
}
【问题讨论】:
标签: ssl amazon-web-services nginx https amazon-ec2