我有一个 SPA ( ReactJSwith React-Router)index.html用作入口点。为了使前端路由器正常工作,我需要index.html为所有匹配的 URL 返回文件。
我试过使用但proxy_pass失败了(见下文),
server {
listen 80;
proxy_set_header Host $http_host;
proxy_set_header x-forwarded-for $remote_addr;
location /appname/(?<section>.*) {
proxy_pass http://cdn.us-west-2.edge.aws/666/index.html;
}
}
Run Code Online (Sandbox Code Playgroud)
我也准备好了,try_files但这似乎只适用于本地文件。
我想要达到的效果,
http://example.com/appnamehttp://cdn.us-west-2.edge.aws/666/index.html应提供静态内容http://example.com/appname/abc http://cdn.us-west-2.edge.aws/666/index.html应提供静态内容http://example.com/appname/abc/def http://cdn.us-west-2.edge.aws/666/index.html应提供静态内容nginx ×1