【问题标题】:NGINX This site can’t be reachedNGINX 无法访问该站点
【发布时间】:2021-07-31 19:57:29
【问题描述】:

我有一个前端反应应用程序,运行在localhost:3000。还有一个运行在localhost:9900 的后端。
我可以通过邮递员(或 curl)localhost:80/api 请求访问我的后端。
但我无法通过网址访问网站或服务器:my-1stconnection.lan.test
有什么问题?

NGINX 配置:

server {
        listen 80;
        listen [::]:80;

        server_name my-1stconnection.lan.test;

        location / {
                proxy_pass http://localhost:3000/;
        }

        location /api {
                proxy_pass http://localhost:9900/;
        }
}

【问题讨论】:

  • 如果my-1stconnection.lan.test 转换为127.0.0.1 这应该可以工作...你检查过这个吗(例如nslookup)?
  • 不,my-1stconnection.lan.test 未解决:server can't find my-1stconnection.lan.test: NXDOMAIN。在浏览器中尝试访问 my-1stconnection.lan.test 时出现错误:无法访问此站点。
  • 那么这个名字从何而来?你是自己随机选择的吗?你认为它应该如何工作?

标签: nginx proxy


【解决方案1】:

为了激活本地服务器,我忘记了一件重要的事情:

127.0.0.1 my-1stconnection.lan.test 转为/etc/hosts

在这个修复之后,一切都开始工作了。

【讨论】:

    猜你喜欢
    • 2017-10-30
    • 1970-01-01
    • 1970-01-01
    • 2019-04-07
    • 2020-07-16
    • 2019-05-20
    • 1970-01-01
    • 1970-01-01
    • 2020-10-24
    相关资源
    最近更新 更多