如果要從本地目錄托管不同的靜態文件,配置可能如下所示: 注意:如果使用root指令,您的位置uri(/,/one)將附加到根目錄路徑。 root指令可以在每個位置塊中用于設置文檔根目錄。http://nginx.org/en/docs/http/ngx_http_core_module.html#root 這就是alias存在的原因。使用alias時,位置將不會成為目錄路徑的一部分。看看這個:http://nginx.org/en/docs/http/ngx_http_core_module.html#alias 1一個域-Multi-Location server { server_name example.com; listen 443 ssl; ..... root /home/user/main/dist; location / { index index.html; # If you have some sort of React or Angular App you might want to use this # try_files $uri $uri/ /index.html; # If you just host a local files (css, js, html, png)... # try_files $uri $uri/ =404; } locatio