微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决努力理解 /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 举报,一经查实,本站将立刻删除。