Node.js 在NGINX上为node js应用程序启用HTTPS不起作用
我使用的是一个简单的hello world Express.JS 8080端口应用程序,部署在Ubuntu服务器上,NGINX反向代理设置如下 该应用程序在http端口上运行良好,但在https端口上运行不正常 nginx版本:nginx/1.10.3 Ubuntu OpenSSL 1.0.2g 2016年3月1日 我的配置文件如下所示:Node.js 在NGINX上为node js应用程序启用HTTPS不起作用,node.js,nginx,https,reverse-proxy,Node.js,Nginx,Https,Reverse Proxy,我使用的是一个简单的hello world Express.JS 8080端口应用程序,部署在Ubuntu服务器上,NGINX反向代理设置如下 该应用程序在http端口上运行良好,但在https端口上运行不正常 nginx版本:nginx/1.10.3 Ubuntu OpenSSL 1.0.2g 2016年3月1日 我的配置文件如下所示: server { listen 80; listen 443 default ssl; server_name
server {
listen 80;
listen 443 default ssl;
server_name localhost;
ssl_certificate /root/mydir/ssl/certificate.crt;
ssl_certificate_key /root/mydir/ssl/private.key;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
对于my domain testdomain.com的http连接,配置工作正常,但对于或,配置完全失败
这个配置出了什么问题
SSL证书由sslforfree.com生成。您好,我仍然收到无法访问错误站点的消息,现在甚至http也无法工作。请帮助使http工作删除强制将http重定向到https重写^https://$http\u host$request\u uri?永久的日志在说什么?nginx access.log是空的,它没有移动:-看一看:谢谢你的帮助,我的问题现在解决了,我没有注意到443端口关闭了。现在它可以正常工作了。
server {
listen 80;
server_name example.com;
# force redirect http to https
rewrite ^ https://$http_host$request_uri? permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /root/mydir/ssl/certificate.crt;
ssl_certificate_key /root/mydir/ssl/private.key;
server_name example.com;
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
....
}