Why does this URL result in a 400 (Bad Request) error?

Igor Sysoev is at rambler-co.ru
Wed Nov 4 12:56:33 MSK 2009


On Wed, Nov 04, 2009 at 09:43:14AM +0000, John Moore wrote:

> Igor Sysoev wrote:
> > On Tue, Nov 03, 2009 at 09:57:16PM +0000, John Moore wrote:
> >
> >   
> >> Igor Sysoev wrote:
> >>     
> >>> You may try to set error_log to info level to see 400 error
> >>> reason.
> >>>
> >>>   
> >>>       
> >> Having tried this, nothing gets written to the error log when the 400 
> >> error is returned.
> >>     
> >
> > Is this URL is proxied ? What signature do you see in 400 message ?
> >
> >
> >   
> Igor, really sorry to have wasted your time. The problem turns out not 
> to be in nginx at all. Yes, nginx is acting as a reverse proxy, in front 
> of Tomcat, and it is evidently Tomcat which is returning the 400 error. 
> The reason I didn't spot this is that there is no sign of this request 
> at all in the Tomcat logs, it's as if the request never got there. The 
> only way I could tell was by the fact that there was a specific response 
> header which could only have come from Tomcat.
> 
> So, that brings me on to another question. Can I use nginx to correct 
> the URL, so that Tomcat doesn't choke on it? That is, can I use some 
> rewrite trickery to URL decode part of the URL, so that
> 
>     _ais_JEzKjKps%2B0%2FAynL0G17OWg?
> 
> becomes
> 
>     _ais_JEzKjKps+0/AynL0G17OWg?

If you set

   location / {
       proxy_pass  http://tomcat;
   }

then nginx passes a unchanged original client request, however, if you set

   location / {
       proxy_pass  http://tomcat/;
   }

then nginx passes unescaped and then escaped again request,
So "+" and "/" will be unescaped in this case.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list