简体   繁体   中英

Node.js on nginx with different port

I have seen few examples in internet but tried none of them is working, can you tell whats wrong i am doing. I have my laravel app on nginx server , now i want to run another node.js app on different port on my server. i have been trying on different ways , but all i am getting " 502 Bad Gateway "

Another note, i have my HTTPS port allowed for port 3000.

Here's my server config codes-

server{
    listen 443 ssl;
#   listen [::]:80 ipv6only=on;
    server_name node.example.com;
    root /home/Tapos/node_modules;
    index index.html index.htm index.js;
    location / {
    try_files $uri $uri/ =404;
#   proxy_pass https://node.example.com;
        proxy_pass https://localhost:3000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}

You would need to add another server block for redirecting the traffic to another nodejs app or update the existing server block to redirect the traffic between your nodejs application based on the URL.

Please add your updated server block or new server block to the question if you need any further help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM