【问题标题】:nginx run npm with non-default port?nginx 使用非默认端口运行 npm?
【发布时间】:2018-07-10 07:08:40
【问题描述】:

我的 Angular 应用程序在根 url 端口 80 中运行,我想访问在端口 8090 上运行的 api。但是当我尝试更改端口时 nginx 监听 8090 它说我有冲突(因为npm 在 8090 运行它)。所以我把它换成了8100。但是,当我尝试访问该端口时,它无法连接。我的目标是能够去http://174.131.183.112:8100 获取我的api。

server {
    listen 8100;
    server_name api._;
    location / {
        proxy_pass http://174.131.183.112:8090;
        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;
     }
}

注意:奇怪的是,如果我没有在 nginx 中运行其他任何东西,那么它仍然使用默认端口 80 连接到我的 api,就好像 8100 根本不存在一样。

【问题讨论】:

  • 哦,是的 - 我在 DigitalOcean 上运行它

标签: nginx nginx-reverse-proxy


【解决方案1】:

我意识到我设置了 ufw 来阻止所有端口。所以我不得不 sudo ufw allow 8100 打开它,现在它可以工作了。

【讨论】:

    猜你喜欢
    • 2019-05-01
    • 2016-04-23
    • 2018-05-05
    • 2014-08-27
    • 2021-05-06
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多