node.js项目在centos中利用nigix强制跳转到https

app.js

app.listen(3030)

nignx

在centos中找到nignx的配置文件default.conf修改:

server {
    listen      80;
    listen      443  ssl; #https

    server_name  www.xx.xxx;

    ssl_certificate      /cert/server.pem;
    ssl_certificate_key  /cert/server.key;
    
    location /{
           proxy_pass http://123.2.2.2:3030;
    }
    if ($scheme = http) {
        return 301 https://$server_name$request_uri;
     }
     }

重启nginx

nginx -s reload

重启项目

node app.js

你可能感兴趣的:(node.js,centos,nignx)