I created two node.js instance on DigitalOcean's Ubuntu machine. Both listen to localhost, with different ports. Then test by curl http:\localhost:${port}. Both worked.
Then I added them to /etc/nginx/site-available/default
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
proxy_pass http://localhost:8837;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /app {
proxy_pass http://localhost:9837;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
Only http://${ip_address}:${port}/ worked.
http://${ip_address}:${port}/app return "Cannot GET /app"
I used express in node.js is it the problem come from?
via Wu Baiquan
No comments:
Post a Comment