找不到404,寻找默认路径' etc/nginx/html/index.html'在NextJS应用程序上
目前,我需要一些我已经陷入困境了几天的404期。我的系统正在运行CentOS7(CPANEL,VPS),它使用Engintron进行Nginx反向代理和PM2来保持我的下一个.js应用程序运行。
default.conf
server {
#listen 80 default_server;
listen 80;
server_name my.domain.name domain.name;
location / {
# reverse proxy for next server
proxy_pass http://127.0.0.1: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 /_next/static/ {
alias path/to/nextjs/static/folder;
expires 365d;
access_log off;
}
# deny all; # DO NOT REMOVE OR CHANGE THIS LINE - Used when Engintron is disabled to block Nginx from becoming an open proxy
# Set the port for HTTP proxying
set $PROXY_TO_PORT 8080;
include common_http.conf;
}
我尚未触摸过的所有其他文件,因此可以安全地将它们排除在外,因为它们是Engintron随附的默认文件。
连接到my.domain.name,给我在控制台中的错误。
"/etc/nginx/html/index.html" is not found (2: No such file or directory), client: ::ffff:my.ip.address, server: my.domain.name, request: "GET / HTTP/2.0", host: "my.domain.name"
我最好的猜测为什么会发生这个问题是因为我的域/服务器无法接收文件,或者根本没有通过代理的许可,因为通过curl http://将数据以127.0.0.0.1:3000获取数据。 127.0.0.1/3000
完全返回我的网站的代码。
对可能导致这一点的任何想法?度过美好的一天:)
I'm currently in need of some help with this 404 issue I've been stuck on for days now. My system is running CentOS7 (CPanel, VPS) and it uses engintron for the nginx reverse proxy and pm2 to keep my next.js application running.
default.conf
server {
#listen 80 default_server;
listen 80;
server_name my.domain.name domain.name;
location / {
# reverse proxy for next server
proxy_pass http://127.0.0.1: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 /_next/static/ {
alias path/to/nextjs/static/folder;
expires 365d;
access_log off;
}
# deny all; # DO NOT REMOVE OR CHANGE THIS LINE - Used when Engintron is disabled to block Nginx from becoming an open proxy
# Set the port for HTTP proxying
set $PROXY_TO_PORT 8080;
include common_http.conf;
}
All the other files I haven't touched, so it's safe to rule them out as they're the default ones that come with engintron.
Connecting to my.domain.name, gives me this error in the console.
"/etc/nginx/html/index.html" is not found (2: No such file or directory), client: ::ffff:my.ip.address, server: my.domain.name, request: "GET / HTTP/2.0", host: "my.domain.name"
My best guess on why this problem occurs is because my domain/server can't receive the files or doesn't have permission through the proxy at all as getting the data at 127.0.0.1:3000 via curl http://127.0.0.1/3000
returns my site's code in full.
Any ideas on what could be causing this? Have an amazing rest of your day :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Engintron可以轻松地使其替代节点应用程序。看看文档(engintron.com/docs)以及WHM>插件> Engintron。
只要您将节点网站加载到给定帐户中的public_html文件夹中(Apache不能以任何一种方式渲染它,因此这不是问题),并且_next/ static/在该public_html文件夹(用于对称的代理)中,然后是节点。您在Engintron的自定义规则中设置的JS代理规则(再次请参见文档)就足以满足您的需求。
我还建议您恢复Engintron的Nginx配置文件中所做的任何更改。
Engintron can make proxying to Node apps easy. Have a look at the docs (engintron.com/docs) as well as the "custom rules" files in WHM > Plugins > Engintron.
As long as you load your Node site in your public_html folder for the given account (Apache cannot render it either way, so it's not an issue) and _next/static/ is inside that public_html folder (for symmetrical proxying), then the Node.js proxy rule you set in Engintron's custom rules (again see the docs) will be sufficient for your needs.
I would also recommend you revert any changes you did in Engintron's Nginx config files.