如何仅在节点应用程序上修复主页加载,其他路由给出404

时间:2019-10-01 01:17:57

标签: node.js nginx ubuntu-18.04

我正在使用nginx的服务器阻止功能将我的节点应用托管在一个子域上。但是我只能访问该应用程序的主页。例如:subdomain.example.com有效,但subdomain.example.com/users提供404

我遵循了Digitalocean上的文档

server {
    listen 80;
    listen [::]:80;
    root /var/www/staging.xxxxxxx.com/html/xxxxxxx/src;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name staging.xxxxxxxx.com www.staging.xxxxxxx.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            # try_files $uri $uri/ =404;

            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;

    }
}

0 个答案:

没有答案