我配置了两个在 nginx 后面运行的节点应用程序。nginx 用作反向代理,一个域重定向到它默认 URL 上的错误应用程序,
app1 端口 3000 域http://www.site1.com和https://www.site1.com
app2 端口 3001 域http://www.site2.com
http://www.site1.com和https://www.site1.com 工作正常并提供 app1
但是当http://www.site2.com它重定向到https://www.site2.com和服务器 app1
但是当请求http://www.site2.com/someurl时,它会服务器 app2
这是nginx配置
站点 1
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.site1.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name www.site.com;
ssl on;
ssl_certificate /certificate.crt;
ssl_certificate_key /psa.rsa;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass …Run Code Online (Sandbox Code Playgroud)