Nginx is not the problem here. It forwards PUT
requests in reverse proxy blocks as expected, if the location
matches the request.
I had another location
directive, which makes sure images are not served via the reverse proxy. It matched everything with .png
(and some other file extensions) in the end, which matched the upload-urls as well.
For the wrong location block, the error 405 is correct. The solution is to make sure the upload requests are actually forwarded into the reverse proxy.
An example for a working reverse proxy configuration:
# proxy requests for /upload the a webapp, which implements PUT
location ^~ /upload {
proxy_pass "https://backendserver:1234/something";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
tcp_nodelay on;
}
The configuration works fine, if there are no other location blocks, which take precedence.
My problem was another block:
# This block matched requests for /upload/somefile.png before the proxy block
location ~* ^(/.*png|/.*jpg|/.*jpeg|/.*gif)$ {
# some directives without proxy_pass
}