我正在尝试使用react-router满足我的路由需求。我尝试将nginx配置为在/ app路由下点击任何内容时使用index.html。但是,当我转到localhost:8000 / app路由时,我继续重定向回localhost:8000 / app。
server {
listen 8000;
server_name localhost;
#access_log logs/host.access.log main;
location /app/ {
try_files $uri $uri/ /index.html;
proxy_pass http://127.0.0.1:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache_bypass $http_upgrade;
}
location / {
proxy_pass http://localhost:8888;
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;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}