简体   繁体   English

安全网址不适用于Nginx + Node

[英]secure url not working with nginx+node

I have a mean stack application which is served via nginx proxy. 我有一个通过nginx代理服务的普通堆栈应用程序。

nginx settings are as below: nginx设置如下:

server {
  listen 443 ssl;
  server_name www.example.com;
  ssl_certificate /home/deploy/www.example.com.chained.crt;
  ssl_certificate_key /home/deploy/example.com.key;

  location / {
    proxy_pass http://127.0.0.1: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; 
  }
}

The express add is setup as below: 快速添加设置如下:

var app = express();
var server = app.listen(8080);

When I access the website via secure URL https://www.example.com 当我通过安全URL https://www.example.com访问网站时

I recieve the following page: 我收到以下页面:

"Moved Temporarily. Redirecting to http://127.0.0.1 " or just a blank page “临时移动。重定向到http://127.0.0.1 ”或只是空白页

The URL http://127.0.0.1 is not being rewritten to https://www.example.com . URL http://127.0.0.1没有被重写为https://www.example.com The default should be equivalent to: 默认值应等于:

proxy_redirect http://127.0.0.1:8080/ /;

The default is not being actioned. 默认值未执行。 Maybe because the proxy_path directive does not include a trailing / or maybe because the application is not specifying a port in its redirect header. 可能是因为proxy_path指令不包含尾随/或者可能是因为应用程序未在其重定向标头中指定端口。

You could try the following: 您可以尝试以下方法:

proxy_pass http://127.0.0.1:8080/;
proxy_redirect default;
proxy_redirect http://127.0.0.1/ /;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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