分类目录归档:Nginx

$realpath_root 和 $document_root 区别

$realpath_root:

an absolute pathname corresponding to the root or alias directive’s value for the current request, with all symbolic links resolved to real paths

如果是符号链接,$realpath_root指向符号链接的真实路径

$document_root:

root or alias directive’s value for the current request

$document_root 是root或alias指定的值

nginx: worker process is shutting down

nginx: worker process is shutting down,这个是nginx reload后可能会出现的,应该是继续处理未结束线程用的。

如果你的超时相关配置设置了很长时间,那么这个线程也会存在很长时间。

Nginx限流

https://blog.csdn.net/m0_45406092/article/details/124713027

要点:

Example Configuration

http {
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

    ...

    server {

        ...

        location /search/ {
            limit_req zone=one burst=5;
        }

rate=1r/s; 表示 1请求每秒,也可以是 rate=30r/m;(30请求每分)

$binary_remote_addr 表示根据 ip v4或者 ip v6地址来限制流量

burst=5;表示突发请求不超过5个

nginx 指定下载文件的文件名

server {
    .....

    location ~* .*\.(doc|txt|jar|zip|apk)(\?.*)?$ {
        if ($request_uri ~* ^.*\/(.*)\.(doc|txt|jar|zip|apk)(\?name=([^&]+))$) {
            add_header Content-Disposition "attachment;filename=$arg_name.$2";
        }
    }

nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32

把server_names_hash_bucket_size改大点即可,可以改成64或128试下,放在http {}里

Syntax:server_names_hash_bucket_size size;
Default:server_names_hash_bucket_size 32|64|128;
Context:http

Sets the bucket size for the server names hash tables. The default value depends on the size of the processor’s cache line. The details of setting up hash tables are provided in a separate document.