簡體   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