为什么可以使用curl访问url但在google chrome浏览器中失败

为什么可以使用curl访问url但在google chrome浏览器中失败

我在 macOS 上的 nginx 中配置 localhost url,如下所示:

➜  nginx git:(master) cat conf.d/reddwarf-admin.conf
server {
        listen 8083;
        server_name admin.reddwarf.com;
        location / {
            proxy_pass http://127.0.0.1:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
        }
        location ^~ /service/ {
            proxy_pass  https://admin.example.top/;
             proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

然后在以下位置配置本地域/etc/hosts

127.0.0.1   admin.reddwarf.com

使用终端中的命令获取网络,如下所示:

curl http://admin.reddwarf.com:8083

获取html成功。下一步,从谷歌浏览器获取网址,显示错误:

This page isn’t workingadmin.reddwarf.com is currently unable to handle this request.
HTTP ERROR 502

我错过了什么吗?我应该怎么做才能使其可以从终端和谷歌浏览器访问?这是我的 macOS dns 配置:

➜  ~ cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
nameserver 192.168.31.1

192.168.x.x我可以使用本地网络IP 地址访问该端口。

相关内容