繁体   English   中英

如何更改角度应用程序的 nginx 配置文件

[英]how to change nginx config file for angular application

我的 angular 应用程序在 nginx 服务器上运行。 当我输入http://**.8.100.248:30749它显示 nginx 正在运行。 (显示默认 index.html)。 但是我的应用程序存在于文件夹名称为test html文件夹中。 所以我的应用程序出现在“html —> test—> index.html”中;;

因此,当我输入http://**.8.100.248:30749/test/index.html我的应用程序在浏览器上运行,但是当我从一个页面路由到另一个页面并reload我的页面时,它给了我404

当我重新加载我的角度路由页面时,Nginx 给了我 404。 所以我更改了 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;
}

任何更新

在您的配置中将root更改为/usr/share/nginx/html/test应该可以解决您的问题。

在您的配置文件中添加以下内容:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM