白日依山尽,黄河入海流。欲穷千里目,更上一层楼。 -- 唐·王之涣

nginx location uri truncate

说明:

location 中的 root 和 alias

  • root 指令只是将搜索的根设置为 root 设定的目录,即不会截断 uri,而是使用原始 uri 跳转该目录下查找文件
  • aias 指令则会截断匹配的 uri,然后使用 alias 设定的路径加上剩余的 uri 作为子路径进行查找

location 中的 proxy_pass 的 uri

  • 如果 proxy_pass 的 url 不带 uri

    • 如果尾部是”/“,则会截断匹配的uri
    • 如果尾部不是”/“,则不会截断匹配的uri
  • 如果proxy_pass的url带uri,则会截断匹配的uri

阅读更多

Nginx - Centos下Nginx报错集合

整理Centos系统下Nginx遇到的问题,一遍后续排查问题方便


[emerg] could not build the server_names_hash…

开始使用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

How to fix

在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

nginx官方对server_name的说明请参考 链接

公众号: DailyJobOps DailyJobOps