我的子域无法使用我的 VPS 和 NGINX 来托管应用程序

时间:2021-07-30 08:44:56

标签: nginx subdomain vps

我正在尝试将我的子域连接到我的 VPS 以托管我的 React/Express 应用程序。

以下是我目前已完成的步骤。

  1. 我在 DNS 设置中创建了我的子域 A 记录,该记录指向 VPS 的 IP。

  2. 我确保运行 dig my_subdomain,结果它指向我的 VPS IP 地址。

  3. 我更改了我的 NGINX 配置,让 server_name 指向我的子域。

  4. 我已经重新启动了 NGINX 服务器。

当我定向到我的子域时,我收到 ERR_CONNECTION_REFUSED 错误,告诉我无法访问我的网站。

还有其他我遗漏的步骤吗?

这是我的 NGINX 配置:

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

        server_name shop.MY_SUBDOMAIN.com;

        location / {
                root /var/www/html;
                index index.html index.htm index.nginx-debian.html;
                try_files $uri /index.html$is_args$args =404;
        }

        location /api {
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_pass http://localhost:6000;
                proxy_cache_bypass $http_upgrade;
        }
}

感谢所有的帮助和建议:)

0 个答案:

没有答案