mkv*_*kvs 3 nginx azure azure-web-app-service
I am deploying a ReactJS application in Azure App Service that runs on Linux container. The ReactJS application has router. The refresh of internal pages failing due to the ReactJS routing. As per React-router and nginx , I can solve this problem by adding following block in nginx.conf
location / {
try_files $uri /index.html;
}
Run Code Online (Sandbox Code Playgroud)
Now my problem is that how can I modify the nginx.conf inside the Azure App Linux container? I tried to copy to /home/site. It did not work. It always taking nginx.conf from /etc/nginx. If I replace that /etc/nginx/nginx.conf with my own version, it will be overwritten on next reboot.
Is there anyway I can use my own nginx.conf? or should I create a custom container to solve it?
mvd*_*gun 11
您实际上可以通过应用程序服务的启动命令修改 nginx 配置。
通过 SSH 连接到您的应用服务。
将默认的 nginx 配置文件复制到您的主目录:
cp /etc/nginx/sites-available/default /home/site/nginx.conf
Run Code Online (Sandbox Code Playgroud)
修改复制的 nginx 配置文件/home/site/nginx.conf并包含您的自定义配置。
vi /home/site/nginx.conf
Run Code Online (Sandbox Code Playgroud)
/home/site/startup.sh创建一个包含以下内容的bash 文件:
cp /home/site/nginx.conf /etc/nginx/sites-available/default
service nginx reload
Run Code Online (Sandbox Code Playgroud)
将您的应用程序服务启动命令设置为/home/site/startup.sh。
在启动过程中,您的应用程序服务将覆盖默认的 nginx 配置并重新加载 nginx 服务。这不是最可维护的解决方案,但它确实有效。
| 归档时间: |
|
| 查看次数: |
10864 次 |
| 最近记录: |