Wednesday, July 27, 2011

nginx 405 Not Allowed

Ever since I was two I have reacted strongly to being told no.

"No you can't" sometimes even brings resentment.

"No you can't, you never will, and you can't change one thing" riles me like nothing else. (well, ok, maybe other things rile me, but whatevs)

For a tool like nginx, a good, capable web server, to repeatedly tell me "405: Not Allowed" is not cool. at. all.

For those of you who aren't terribly fond of technical discussions but are reading this for other reasons, you are perfectly welcome to ignore anything past this paragraph. Thanks for reading. :)

For those who have been Googling this for hours, please stay with me:

For one, nginx caching is powerful, and if you're using version 0.8 or newer it is most likely not the problem.

nginx is smart. If you try to HTTP POST to a static page, it will complain. POSTing is only useful for pages backed by server-side code (in my limited experience).

"But," you might say, as I did, "My nginx.conf very carefully guides all requests to my dynamic web server using the proxy_pass parameter!"

Remember how your nginx.conf uses those pesky semicolons? Think of C. Shudder. Reminisce if you like-- my point is that nginx.conf is, after a manner, a procedural programming environment. If you put your root server block above your dynamic server block, it will interpret them in the order it read them. Every time.

Solution? Change the block order or--as I did--merge the blocks and drop your "location /" section down to the end.

I hope this helps you. Good luck.

:)

No comments:

Post a Comment