nginx proxy pass Node, SSL?

前端 未结 1 1159
臣服心动
臣服心动 2020-11-30 19:56

my nginx server is actually proxying my node backend (which listens on port 3000) with a simple:

location /api/ {
proxy_pass http://upstream_1;
}


        
相关标签:
1条回答
  • 2020-11-30 20:17

    If you're using nginx to handle SSL, then your node server will just be using 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; 
          } 
       }
    
    0 讨论(0)
提交回复
热议问题