Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx Next.js直接从url更改不起作用_Nginx_Next.js - Fatal编程技术网

Nginx Next.js直接从url更改不起作用

Nginx Next.js直接从url更改不起作用,nginx,next.js,Nginx,Next.js,Next.js版本10.0.6- 节点版本12.18.4- Linux 18.04 在我的服务器上,我试图将URL直接更改为about页面(通过键入to URL,而不是单击链接),但它给了我一个502坏网关。任何复制粘贴到URL都不起作用。当我单击“关于”链接时,只有在我的导航栏中才能导航到“关于”页面 例如: www.example.com/about 在我的电脑上,在开发模式下的操作效果非常好。问题出在我的服务器上 我的部署步骤: package.json文件: "scripts

Next.js版本10.0.6- 节点版本12.18.4- Linux 18.04

在我的服务器上,我试图将URL直接更改为about页面(通过键入to URL,而不是单击链接),但它给了我一个502坏网关。任何复制粘贴到URL都不起作用。当我单击“关于”链接时,只有在我的导航栏中才能导航到“关于”页面

例如:

www.example.com/about
在我的电脑上,在开发模式下的操作效果非常好。问题出在我的服务器上

我的部署步骤:

package.json文件:

"scripts": {
    "dev": "next dev",
    "build": "next build && next export",
    "start": "next start"
  },

npm run build
我从“out”文件夹中取出所有文件,并将它们放在我的服务器上

nginx conf文件:

server {
    listen myip:80 default_server;
    listen [::]:80 default_server;
    server_name example.com www.example.com;

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;
 }

location ~ /.well-known {
  allow all;
}

 location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   /home/admin/web/example.com/stats/;
        include /home/admin/conf/web/example.com.auth*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.example.com.conf*;
}
我重启了Nginx的服务,启动了pm2

sudo service nginx restart

pm2 start npm --name "next" -- start
我做错了什么?我的配置正确吗


如果您需要任何其他信息,请随时询问。

您可以将
trailingSlash:true
添加到
next.config.js
中,以便
/about
可以路由到HTML文件。这是Next.js 9之前的默认行为,但现在需要显式启用

//next.config.js
module.exports={
真的吗
}

在URL末尾添加
.html
是否可以使页面正常工作?不,不起作用。现在整个网站都关闭了。尝试重新启动服务器和pm2,但没有任何结果。很公平。您的问题可能需要一个
nginx
解决方案,遗憾的是我并不熟悉。