[英]NodeJS & Nginx Proxy not working
I've written a sailsjs based application, deployed in one of my VPS. 我已经编写了一个基于sailsjs的应用程序,并部署在我的VPS之一中。 App is running in production mode using pm2.
应用正在使用pm2在生产模式下运行。 I can access through public_ip:1338 , everything seems normal.
我可以通过public_ip:1338访问,一切似乎都很正常。
So installed nginx,configured proxy_pass, installed letsencrypt ssl. 因此安装了nginx,配置了proxy_pass,安装了letencrypt ssl。 When I'm trying to access domain, I'm seeing Nginx Default Page with SSL working, not the NodeJS (SailsJS) application.
当我尝试访问域时,我看到带有SSL的Nginx默认页面有效,而不是NodeJS(SailsJS)应用程序。
Here is nginx conf file 这是nginx conf文件
server {
listen 80;
server_name domain.net www.domain.net;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl spdy;
listen [::]:443 ssl spdy;
ssl_certificate /etc/letsencrypt/live/domain.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.net/privkey.pem;
server_name domain.net;
location / {
proxy_pass http://localhost:1338;
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;
}
}
I need to sort out the issue. 我需要解决问题。 Can you guys instruct me to fix the issue?
你们可以指导我解决此问题吗?
I had the same problem. 我有同样的问题。 Followed this guide and it worked.
遵循本指南并奏效。 I did need to include
include /etc/nginx/sites-enabled/*
in nginx.conf to make it work. 我确实需要在nginx.conf中
include /etc/nginx/sites-enabled/*
才能使其正常工作。 And here's what's in my default file in the sites-enabled
folder: 这是
sites-enabled
文件夹中我的默认文件中的内容:
server {
listen 443 ssl;
server_name sitename.com www.sitename.com;
ssl_certificate /etc/letsencrypt/live/sitename.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sitename.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDH$
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;
location ~ /.well-known {
allow all;
}
location / {
proxy_pass http://localhost:8080;
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;
}
}
server {
listen 80;
server_name sitename.com www.sitename.com;
return 301 https://$host$request_uri;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.