nginx配置proxy_pass之后返回404问题及Nginx host相关变量说明
一次业务增加常规性 proxy_pass 之后,请求的接口直接返回404,相同的配置在不同的域名下,之前的配置的是好的,本次在其他域名下新增相同配置出现404,问题排查和分析,需要了解Nginx中host相关的变量, $host/$http_host/$proxy_host
阅读更多location 中的 root 和 alias
location 中的 proxy_pass 的 uri
如果 proxy_pass 的 url 不带 uri
如果proxy_pass的url带uri,则会截断匹配的uri
整理Centos系统下Nginx遇到的问题,一遍后续排查问题方便
开始使用nginx只有一个虚拟主机,默认server_name 会使用 localhost, 今天配置nginx的server_name是一个正式存在的域名的时候,报错如下:
root@pts/0 $ nginx -t
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed
在nginx的配置文件nginx.conf的http段添加如下配置:
# vi /etc/nginx/nginx.conf
...
http {
...
server_names_hash_max_size 512;
server_names_hash_bucket_size 128;
...
}
...
root@pts/0 $ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
server_name
的说明请参考 链接