NGINX 設定根位置未考慮在內

NGINX 設定根位置未考慮在內

這可能是一個愚蠢的問題,但我無法將 nginx 設定為從自訂位置(即預設根目錄之外)的資料夾中提供文件,我在 docker 容器內使用 nginx,但這應該會改變進程。

我看過以下帖子這裡這裡也許使用別名可以幫助我,但我想知道為什麼以下不起作用。

我有一個保存我的網站的資料夾:/mirrors/my-folder nginx.conf 設定為預設值,它包括以下特定配置:/etc/nginx/conf.d/my-server.conf

server {
    listen 10000;

    root /mirrors/my-folder;
    location / {
        autoindex on;
    }
}

當我嘗試訪問伺服器時http://我的ip:10000/ 我得到預設的歡迎頁面,從 /usr/share/nginx/html 提供,我希望獲得 /mirrors/my-folder 的根目錄...

這是access.log

10.x.x.x - - [16/Feb/2018:17:46:23 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36" "-"

以及 error.log(顯示缺少的圖示):

2018/02/16 17:45:59 [error] 13#13: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 10.x.x.x, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "10.x.x.x:10000", referrer: "http://10.x.x.x:10000/"
10.0.0.113 - - [16/Feb/2018:17:45:59 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http://10.0.0.124:10000/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36" "-"

知道我的配置可能有什麼問題嗎?

答案1

每當對 nginx.conf 檔案進行任何更改時。請重新載入 nginx 以帶來變更。指令是 nginx -s reload。

相關內容