[英]Nginx adding path to location
我是 Nginx 的新手,無法顯示我的 index.html
我的基本配置如下所示:
server {
listen 80;
listen 8080;
root /opt/app/static;
index index.html
location /mypath {
alias /opt/app/static/;
autoindex off;
}
location = /favicon.ico {
alias /opt/app/static/favicon.ico;
}
}
我試圖訪問的 url 應該顯示我的 index.html,看起來像這樣https://my_subdomain.test.domain.com/mypath
但是,我收到 404 錯誤。
[error] 9#0: *12 "/opt/app/static/mypath/index.html" is not found (2: No such file or directory), client: xxx.xx.x.x, server: , request: "GET /mypath/ HTTP/1.1", host: "my_subdomain.test.domain.com"
Nginx 正在將 url 路徑添加到我的 index.html 的搜索路徑中
我也嘗試將location /mypath {
設置為location / {
沒有成功。
如何設置我的配置,以便在訪問https://my_subdomain.test.domain.com/mypath
nginx 顯示位於路徑/opt/app/static/
index.html?
您的服務器正在尋找 /mypath/ 但您只告訴它尋找 /mypath
嘗試
location ^/mypath {
alias /opt/app/static/;
autoindex off;
}
或者
location ~ /mypath {
alias /opt/app/static/;
autoindex off;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.