简体   繁体   中英

Configure Nginx connection timeout for specific request pattern

In application I want to increase connection timeout as there is functionality to upload huge files. Currently I found the next properties:

 proxy_connect_timeout     20;
 proxy_send_timeout        20;
 proxy_read_timeout        20;

But the thing is that I looking to not allow so long connection through all endpoint but only for particular one.

Is there some way to configure Nginx "connection timeout" for particular request pattern?

Yes, One of the nice things about nginx is that you can set values in a hierarchy depending on locations, paths, parameters. source IP addresses... basically on any metadata.

server {
    listen 443 ssl http2;
    ....
    # default timeouts here
    proxy_connect_timeout <smallval>;
    proxy_send_timeout <smallval>;
    proxy_read_timeout <smallval>;

    location /biguploadshere {
        proxy_connect_timeout <bigval>;
        proxy_send_timeout <bigval>;
        proxy_read_timeout <bigval>;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM