【问题标题】:nginx virtual hosting working locally but not globallynginx 虚拟主机在本地工作,但不在全球范围内工作
【发布时间】:2021-11-22 02:55:41
【问题描述】:

当我在本地主机上使用 curl 时它的工作。

root@ip-10-87-3-236:/etc/nginx# curl -o /dev/null -s -w "%{http_code}\n" http://localhost/ib

Output :

200

但是当我通过互联网连接到浏览器时,我得到了

Not Found
The requested resource was not found on this server.

nginx 配置:

server {
    listen 80;
    server_name localhost;
    location /ib {
        proxy_pass http://localhost:3000; #whatever port your app runs on
        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;
    }
    
}

请在此处提供帮助或分享任何可能非常有用的文档

谢谢

【问题讨论】:

  • 能够 curl localhost/ib 它将给出 200 但 127.0.0.1/ib 输出` 未找到

    未找到

    在此服务器上未找到请求的资源。

    `无法理解请在此处帮助跨度>

标签: nginx hosting virtual


【解决方案1】:

您已将localhost 指定为您的server_name。如果您想通过 Internet 和/或使用您选择的域名进行这项工作,例如 example.com,请将 server_name 设置为域名。这将解决您的问题。

参考:https://nginx.org/en/docs/http/ngx_http_core_module.html#server_name

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-29
    • 2014-07-04
    相关资源
    最近更新 更多