努力理解 /etc/nginx/sites-available/default

问题描述

我有网址 http://www.acubestory.com,它会将人们指向我的 IP 地址 http://35.194.72.130/我有一个允许用户发帖的按钮,但是会出现 504 错误。我认为这与我在 /etc/Nginx/sites-available/default

下面的文件有关
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html;
        # Add index.PHP to the list if you are using PHP
        index index.html index.htm index.Nginx-debian.html;
        server_name _;
            location /api {
        proxy_pass http://localhost:3001;
        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;
    }
        location / {
        proxy_pass http://localhost:3000;
        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;
    }
}

我不太明白如何正确设置。我是否需要将 www.acubestory.com 添加到我的 server_name 中,然后为两个 proxy_pass 添加 http://35.194.72.130?您可以在此处看到数据库中没有任何内容http://35.194.72.130/api/list

编辑:它在我的本地主机上运行时有效。

export function addTime(name,time) {
    return fetch('http://localhost:3001/addtime',{
        method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ name,time }) 
    })
}

我将“http://localhost:3001/addtime”更改为 'http://35.194.72.130/api/addtime'

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)