【发布时间】:2018-10-10 13:09:15
【问题描述】:
我有一个在端口 3000 上运行的 next.js 服务器,并且我有静态构建(使用 create-react-app 创建),它应该是管理面板。所以它看起来像这样
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/city-am-club/admin/build/;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /admin/ {
root /usr/share/nginx/myproject/admin/build;
index index.html index.htm;
try_files $uri /index.html;
default_type "text/html";
}
location / {
rewrite /(.*) /$1 break;
proxy_pass http://127.0.0.1:3000;
}
}
我知道位置应该与 admni 面板一样,因为位置是根路径之后的路径。
location / {
root /usr/share/nginx/myproject/admin/build;
index index.html index.htm;
try_files $uri /index.html;
default_type "text/html";
}
无论如何,我真的不知道如何正确配置。现在我无法获取我的构建文件,我尝试了这个配置的许多不同变体。 ATM 当我的所有路由location / 时,我有一个行为,即使我尝试对/admin 做出反应,它也会向我显示 404 页面(locations / 服务器模板的自定义页面)。
【问题讨论】:
标签: nginx