我有一个Web应用程序,它使用Django作为后端,并使用一些前端,而ReactJS则完全使用前端。我正在设置我的Nginx配置,并且试图使Nginx仅在“ /”位置上,然后在其余位置上,使其希望proxy_pass来自React的index.html文件。
这是我当前在站点可用下的Nginx配置。因此,唯一没有前缀“ / home /”或“ / app /”的网址就是首页。我希望Django提供首页,然后由ReactJS提供其余部分。
server {
listen 80;
root /home/route/to/my/ReactJS/build;
server_name www.mydomain.com;
location = /favicon.ico { log_not_found off; }
location / {
include proxy_params;
proxy_pass http://0.0.0.0:8000;
}
location /home/ {
try_files $uri $uri/ /index.html;
}
location /app/ {
try_files $uri $uri/ /index.html;
}
}
Run Code Online (Sandbox Code Playgroud)
让我知道您是否需要更多详细信息,或者我可以解决这些问题。
谢谢!