小编Ale*_*der的帖子

Nginx proxy_cache_key 和 HEAD->GET 请求

我有以下 Nginx 配置:

http {
    ...    
    proxy_cache_path  /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
    proxy_temp_path /var/tmp;
    ...

    upstream webhook_staging {
        server 127.0.0.1:4001;
        keepalive 64;
    }    

    location /webhooks/incoming_mails {
        client_max_body_size 60m;
        proxy_set_header     X-Real-IP $remote_addr;
        proxy_set_header     X-Forwarded-For $remote_addr;
        proxy_set_header     X-Forwarded-Proto $scheme;
        proxy_set_header     Host $http_host;
        proxy_set_header     Connection "";
        proxy_http_version   1.1;

        # Does not work for HEAD requests
        #>> proxy_cache one;
        #>> proxy_cache_key      $scheme$host$request_uri;

        proxy_pass           http://webhook_staging;
    }
}
Run Code Online (Sandbox Code Playgroud)

上游服务器是一个常规的 Node.js 进程。如果我激活proxy_cache_*上面的指令,HEAD请求就会被传递GET到上游服务器。如果我停用指令,HEAD请求将作为请求传递HEAD,一切都很好。

有什么建议么?

谢谢!

nginx reverse-proxy node.js

3
推荐指数
1
解决办法
7714
查看次数

标签 统计

nginx ×1

node.js ×1

reverse-proxy ×1