Static or dynamic content

Francis Daly francis at
Thu Sep 29 22:02:28 UTC 2016

On Wed, Sep 28, 2016 at 11:01:36AM +0000, Jens Dueholm Christensen wrote:

Hi there,

> I've got an issue where nginx (see below for version/compile options)
> returns a 405 (not allowed) to POST requests to clients when the upstream
> proxy returns a 503.

I don't see that, when I try to build a test system.

Are you doing anything clever with error_page or anything like that?

> My config is basicly this

My config is exactly this:

http {
  server {
    listen 8080;
    location / {
      root /tmp;
      try_files /offline.html @xact;
    location @xact {

  server {
    listen 8082;
    return 503;

Do you see the problem when you test with that?

(The file /tmp/offline.html does not exist.)

If not, what part of your full config can you add to the 8080 server
which causes the problem to appear?

  curl -i

does a GET.

  curl -i -d k=v

does a POST. (Use -v instead of -i for even more information.)

> When the request method is a POST nginx transforms this to a 405 "not
> allowed", which is - as far as I can understand from a number of posts
> found googling - is to be expected when POSTing to a static resource.

If you can build a repeatable test case -- either like the above, or
perhaps configure a HAProxy instance that will return the 503 itself --
then it should be possible to see what is happening.

> An individual backend instance can also return a 503 error if it
> encounters a problem servicing a request.
> That 503 response is sent back to HAProxy, which parses it along to
> nginx, which returns the 503 to the client (and it's NOT converted into
> a 405!), so I know that nginx doesn't translate all 503s to 405s if it's
> generated by a backend instance even if the request is POSTed.

If you can see the bytes on the wire between HAProxy and nginx in both
cases, the difference may be obvious.

> This leads me to think that somehow HAProxy does not provide the
> correct headers in the 503 errorpage to make nginx assume the response
> from HAProxy isn't dynamic.

I suspect that that is incorrect -- 503 is 503 -- but a config that
allows the error be reproduced will be very helpful.


Francis Daly        francis at

More information about the nginx mailing list