I've set up nginx (on Windows) as a front end for Tomcat. Accessing the Tomcat webapp works perfectly when I go directly to Tomcat from either Firefox or IE and when I access it from Java code. It also works perfectly the first time I request it from nginx, but the second time I request it from nginx there is a 60 second delay before nginx responds. Stopping the request in the browser resets the behaviour, so the next response returns immediately and the one following again waits 60 seconds.
On the requests where there is a delay, Nginx sends two upstream requests ("request A" and "request B"). Request A times out after 60 seconds, then request B succeeds. Tomcat does not log request A, so it apparently does not receive it, but responds immediately to request B.
This happens with Nginx's upstream connection set to the default (http 1.0) and also set to use http 1.1 with keepalive 16. It does not appear to be a Tomcat problem because it happens even if I bounce Tomcat between the first and second request (so Tomcat doesn't know it's the second request).
My only other clue is that curl sometimes times out after exactly 150 seconds when accessing the Tomcat url.
I am completely baffled, but it could be something very simple. Any ideas would be appreciated.
Conf file extract (with http/1.0):
server {
<snip>
location / {
proxy_pass http://localhost:8080;
}
Conf file extract (with http/1.1):
upstream tomcat {
server localhost:8080;
keepalive 16;
}
server {
<snip>
location / {
proxy_pass http://tomcat;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
On the requests where there is a delay, Nginx sends two upstream requests ("request A" and "request B"). Request A times out after 60 seconds, then request B succeeds. Tomcat does not log request A, so it apparently does not receive it, but responds immediately to request B.
This happens with Nginx's upstream connection set to the default (http 1.0) and also set to use http 1.1 with keepalive 16. It does not appear to be a Tomcat problem because it happens even if I bounce Tomcat between the first and second request (so Tomcat doesn't know it's the second request).
My only other clue is that curl sometimes times out after exactly 150 seconds when accessing the Tomcat url.
I am completely baffled, but it could be something very simple. Any ideas would be appreciated.
Conf file extract (with http/1.0):
server {
<snip>
location / {
proxy_pass http://localhost:8080;
}
Conf file extract (with http/1.1):
upstream tomcat {
server localhost:8080;
keepalive 16;
}
server {
<snip>
location / {
proxy_pass http://tomcat;
proxy_http_version 1.1;
proxy_set_header Connection "";
}