nginx访问本地目录一直不好使_nginx 配置根目录不生效问题
無論如何配置ngnix.conf,還是配置/etc/nginx/conf.d/xxxx.conf 文件的配置,都無法實現proxy_pass功能!
為啥……?
原來新版本的nginx的ngnix.conf文件增加了一行:
include /etc/nginx/sites-enabled/*
而這個目錄底下有一個default文件,這個文件定義了:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
由于該include指令在nginx.conf文件中是最后一個,所以,前面配置的
server{
listen 80;
location / {
# 所有你的配置都不會生效,會被后面的缺省配置覆蓋掉!!
proxy_pass http://localhost:8080/
}
}
如此一來,如果需要配置80的代理,你不能在ngnix 文件,或者conf.d目錄下,而應該替換/etc/nginx/sites-enabled/default文件中的配置。
或者把include /etc/nginx/sites-enabled/*注釋掉。
總結
以上是生活随笔為你收集整理的nginx访问本地目录一直不好使_nginx 配置根目录不生效问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 外星人入侵 python 飞船位置_《p
- 下一篇: 检测网络耗时_无人机替代桥梁检测车检测桥