[英]how to change nginx config file for angular application
My angular application is running on nginx server.我的 angular 应用程序在 nginx 服务器上运行。 When I type
http://**.8.100.248:30749
it show nginx is running.当我输入
http://**.8.100.248:30749
它显示 nginx 正在运行。 (Showing default index.html). (显示默认 index.html)。 But my application is present in
html
folder having folder name test
.但是我的应用程序存在于文件夹名称为
test
html
文件夹中。 So my application present in “html —> test—> index.html”;;所以我的应用程序出现在“html —> test—> index.html”中;;
So when I type http://**.8.100.248:30749/test/index.html
my application run on browser, but when I route from one page to another and reload
my page it gives me 404
.因此,当我输入
http://**.8.100.248:30749/test/index.html
我的应用程序在浏览器上运行,但是当我从一个页面路由到另一个页面并reload
我的页面时,它给了我404
。
Nginx gives me 404 when I reload my angular routed page.当我重新加载我的角度路由页面时,Nginx 给了我 404。 So I changed the nginx config but still not success
所以我更改了 nginx 配置但仍然没有成功
location / {
root /usr/share/nginx/html;
index index.html index.htm;
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
try_files $uri$args $uri$args/ $uri $uri/ /test/index.html =404;
}
any update任何更新
在您的配置中将root
更改为/usr/share/nginx/html/test
应该可以解决您的问题。
In your config file add the following:在您的配置文件中添加以下内容:
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.