微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Nginx配置流星

我的问题是如何让Nginx将域(www.example.com)转发到没有ssl的同一台服务器上的流星应用程序.

这是详细信息:
我正在尝试使用Nginx在我自己的服务器上托管由meteor制作的应用程序.我已经检查了大量我在网上找到的不同的配置文件(其中大部分已过时)但我似乎无法让Nginx将我的域名转发到端口3000,其中meteor可以接收它并处理网络页.

Nginx代理端口的最新配置是:

upstream default {
        server 127.0.0.1:3000;
}

server {
        listen 80;
        server_name localhost;

        location / {
                proxy_pass http://default/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $http_host;

                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forward-Proto http;
                proxy_set_header X-Nginx-Proxy true;

                proxy_redirect off;
        }
}

我稍微修改了一下我认为对我的设置是正确的.我正在使用Nginx中的配置文件,我使用“meteor create html”在/usr/share / Nginx / html中创建了一个流星应用程序.

我知道使用认设置是不好的习惯,但我只是试图让流星应用程序首先运行.

我应该安装所有依赖项:meteor,nodejs,mongodb和Nginx.

我发现很多更新的Nginx配置都使用SSL,我不打算使用它.我不知道如何根据我的需要修改它们.

有人可以解释为什么这个配置不起作用或者我错过了让Nginx指向我的meteor应用程序www.example.com:3000?

提前致谢.

附:

我已经能够使用VM完成相同的设置,使用完全相同的配置文件.我不知道我错过了哪一步.

解决方法:

问题是proxy_pass指令中的尾随反斜杠.应该是proxy_pass http:// default;.感谢anatoly指出这一点.

更新:
Nginx documentation有点困惑,但突出显示了带有/不带URI的proxy_pass之间的区别:

A request URI is passed to the server as follows:

If the proxy_pass directive is specified with a URI, then when a
request is passed to the server, the part of a normalized request URI
matching the location is replaced by a URI specified in the directive:

location /name/ {
    proxy_pass http://127.0.0.1/remote/;
}

If proxy_pass is specified without a URI, the request URI is passed to
the server in the same form as sent by a client when the original
request is processed, or the full normalized request URI is passed
when processing the changed URI:

location /some/path/ {
    proxy_pass http://127.0.0.1;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐