I have a very strange problem with a Java Restlet server behind a reverse proxy.
I am using nginx to redirect an URL to a Restlet server on port 8182. The server is configured like this:
server {
listen 8080;
server_name localhost;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
allow all;
root C:/Users/Cyrille/www;
index index.html index.htm;
}
location /proxy/ping {
proxy_pass http://localhost:8182/ping;
}
}
When I open a browser or use wget to access http://localhost:8080/proxy/ping
, the request is proxied to Restlet. It answers with simply "pong", and its log displays:
Oct 29, 2013 11:45:04 AM org.restlet.engine.log.LogFilter afterHandle
INFO: 2013-10-29 11:45:04 127.0.0.1 - - 8182 GET /ping - 200 4 - 6 http://localhost:8182 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 -
The problem is that the browser doesn't seem to ever receive the response. It just times out after a few minutes with an error 504: Gateway Time-out. If I access directly http://localhost:8182/ping
, the request completes immediately.
When can the request be blocked in? I have disabled any firewall or anti-virus. I have swapped nginx with Apache and I obtain exactly the same behaviour. I am on Windows 8.
It turned out that it is a bug in Restlet: when the HTTP header contains "Connection:Close", the server will not send a response.
I made Nginx not send this header with the following modification and it worked.
location /proxy/ping {
proxy_pass http://localhost:8182/ping;
proxy_set_header Connection "";
}
Here is the link to the (still not fixed 3 years after it has been opened) Restlet bug: http://restlet.tigris.org/issues/show_bug.cgi?id=1191