Disable keep_alive based on specific useragent

Robert Mueller robm at fastmail.fm
Mon Nov 17 04:52:46 UTC 2014


Due to a bug in iOS 8, I want to disable http keep-alive for all iOS 8
useragents for now.

https://github.com/AFNetworking/AFNetworking/issues/2314

I can't see a way to do this in nginx at the moment.


The docs for keep_alive disable only talk about msie6 and safari.

http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_disable

And indeed, checking the code shows that it's a bitfield with only a few
fixed possible values.


All our requests are proxied to a backend, and I obviously could easily
detect the user-agent on the backend, but I can't see any way to
indicate back to nginx that it should drop the connection to the client
after returning the response (e.g. there's no x-accel-disable-keepalive
or something like that).


I had a quick look through the code, and can't see anything obvious. No
configuration options, no upstream response headers, nothing even in the
nginx lua integration that could do this.

Am I missing something? It's a bit annoying that keepalive_disable can't
take an arbitrary regexp if people really want...

-- 
Rob Mueller
robm at fastmail.fm



More information about the nginx mailing list