當我執行“w3m http://localhost/foo/test.html”時,我不明白我的 nginx 不從“/var/www/html/foo/”提供檔案?盡管 '/var/www/html/foo/' 中存在 test.html,但我收到 404 錯誤。當我檢查日志時,我看到它在“/var/www/html/nginx/foo/test.html”中尋找頁面。
user nobody nogroup;
worker_processes 2;
events {
worker_connections 512;
}
http {
server {
listen *:80;
listen *:1026;
server_name "test";
root /var/www/html/nginx/ ;
location foo/ {
alias /var/www/html/foo/ ;
}
}
}
arek@127:~$ ls /var/www/html/nginx
test.html
arek@127:~$ ls /var/www/html/foo
index.html test_bigger.html test.html text.html
arek@127:~$
當我檢查日志時,我看到它在“/var/www/html/nginx/foo/test.html”中尋找頁面
2022/09/03 02:36:05 [error] 139475#139475: *2 open() "/var/www/html/nginx/foo/test.html" failed (2: No such file or directory), client: 127.0.0.1, server: test, request: "GET /foo/test.html HTTP/1.0", host: "localhost"
當我在“/var/www/html/”上更改我的根路徑時,它的作業原理。
uj5u.com熱心網友回復:
嘗試使用這樣的服務器配置塊,它在我的服務器上作業。從根中洗掉了尾部斜杠,并在foo/. 還default_type為位置添加了一個。如果您仍然收到錯誤,請使用顯示查詢路徑的日志進行評論。
server {
listen 80;
listen 1026;
server_name "test";
root /var/www/html/nginx;
location /foo/ {
alias /var/www/html/foo/;
default_type "text/html";
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/503820.html
上一篇:Nginx配置;在其他容器中呼叫api給出405錯誤
下一篇:在隱藏之前無法專注于物件(反應)
