我的 nginx 服务器实际上是用一个简单的方法代理我的节点后端(监听端口 3000):
location /api/ {
proxy_pass http://upstream_1;
}
其中upstream_1是我在nginx.conf中定义的节点集群(在端口3000上)。
我必须通过 http 连接添加 SSL,所以我有以下问题:我只需要配置 nginx 来启用 ssl 吗?它会自动“解密”请求并将其未加密地传递给能够正常处理它的 Node?或者我是否需要配置 Nodejs 以支持 ssl?
如果您使用 nginx 来处理 SSL,那么您的节点服务器将仅使用 http。
upstream nodejs {
server 127.0.0.1:4545 max_fails=0;
}
server {
listen 443;
ssl on;
ssl_certificate newlocalhost.crt;
ssl_certificate_key newlocalhost.key;
server_name nodejs.newlocalhost.com;
add_header Strict-Transport-Security max-age=500;
location / {
proxy_pass http://nodejs;
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-Proto https;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)