spa*_*ick 26 reverse-proxy nginx node.js
我的nginx服务器实际上是用一个简单的代理我的节点后端(它在端口3000上侦听):
location /api/ {
proxy_pass http://upstream_1;
}
Run Code Online (Sandbox Code Playgroud)
其中upstream_1是我在nginx.conf中定义的节点集群(在端口3000上).
我将不得不通过http连接添加SSL,所以我有以下问题:我是否只需要配置nginx来启用ssl?它会自动"解密"请求并将其解密传递给Node,它将能够正常处理它吗?或者我是否还需要配置Nodej以支持ssl?
Bil*_*ill 75
如果您使用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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18015 次 |
| 最近记录: |