Proxy non persistent client connections to persistent upstream connections
Richard Jennings
richard.jennings at switchconcepts.com
Mon Aug 10 08:18:41 UTC 2015
I would like to be able to proxy non persistent client http connections to
persistent upstream connections on a Linux system, both to reduce the
number of connections and the upstream latency.
I have experimented with keepalive and proxy_pass.
To observe performance I used log_format upstreamlog '[$time_local] $status
$connection $connection_requests $request_time'; and $ lsof -Pni
What I think I have found is that some of the time persistent upstream
connections are reused, but very often they are not. I believe the
occasions where upstream connections are reused are possible because by
chance the client connection has been reused.
Is there a way to make this work?
Regards
Example configuration
log_format upstreamlog '[$time_local] $status $connection
$connection_requests $request_time';
upstream google {
server google.com:80;
keepalive 10;
}
upstream yahoo {
server yahoo.com:80
keepalive 10;
}
server {
listen 8080;
server_name 10.0.0.1;
proxy_connect_timeout 500ms;
proxy_send_timeout 500ms;
proxy_read_timeout 500ms;
send_timeout 500ms;
location /status {
stub_status on;
}
location /google {
proxy_pass http://www.google.com;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host google.com;
access_log /var/log/google.log upstreamlog;
}
location /yahoo {
proxy_pass http://www.yahoo.com;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host yahoo.com;
access_log /var/log/yahoo.log upstreamlog;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20150810/604a4083/attachment.html>
More information about the nginx
mailing list