1

我正在尝试为我的 reactjs SPA 应用程序的“admin”文件夹设置新的位置规则。它使用 Kestrel 作为 Web 服务器,使用 Nginx 作为代理。

我已经有一个配置,可以很好地将所有请求重定向到 index.html 文件,该文件包含必要的 javascript 逻辑:

location /favicon.ico { 
proxy_pass http://localhost:5000; 
proxy_http_version 1.1; 
proxy_set_header Upgrade $http_upgrade; 
proxy_set_header Connection keep-alive; 
proxy_set_header Host $host;    
} 

location ~ ^/(fonts|img|js|lib|script|style)/ { 
proxy_pass http://localhost:5000; 
proxy_http_version 1.1; 
proxy_set_header Upgrade $http_upgrade; 
proxy_set_header Connection keep-alive; 
proxy_set_header Host $host;    
} 

location / { 
try_files $uri /index.html; 
proxy_pass http://localhost:5000; 
proxy_http_version 1.1; 
proxy_set_header Upgrade $http_upgrade; 
proxy_set_header Connection keep-alive; 
proxy_set_header Host $host; 
} 

现在我需要为 /admin/ 文件夹添加规则,它将所有请求路由到 /admin/index.html,一旦 /admin/ 是路径的一部分,但以下内容不起作用:

location /admin/ { 
try_files /index.html $uri; 
proxy_pass http://localhost:5000; 
proxy_http_version 1.1; 
proxy_set_header Upgrade $http_upgrade; 
proxy_set_header Connection keep-alive; 
proxy_set_header Host $host; 
} 

我做错了什么?

谢谢,安东

4

0 回答 0