<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Tahoma,Arial,Helvetica,sans-serif'>
<p>Hi folks,<br />I'm using Nginx as a WebDAV server using nginx-dav-ext-module. Now I needed to add an authentication layer to the WebDAV server which couldn't only be relying on a static htpasswd file. So I looked around and found the ngx_http_auth_request_module of Maxim Dounin. Now, once a request comes in, Nginx asks my web app, which is written in python using Pyramid framework, to authenticate the user. When the method is GET, PROPFIND, OPTION, DELETE, etc. it works very well, but the problem is that in case the HTTP method is PUT, it fails! I'm sure the problem isn't with the python code as the subrequest, which ngx_http_auth_request is supposed to make, doesn't even reach my web app. As soon as the auth_request line in the config file is commented, uploading files with PUT works. <br />My configuration is as follows:<br /><br />server {<br />    listen      8080;<br />    root /L/;<br />    charset         utf-8;<br />    location /disks/ {<br />        auth_request /auth_webservice;<br />        client_body_temp_path /tmp/client-tmp 1 2;<br />        create_full_put_path on;<br />        client_max_body_size 2000m;<br />        dav_access user:rw group:rw all:r;<br />        dav_methods PUT DELETE MKCOL COPY MOVE;<br />        dav_ext_methods PROPFIND OPTIONS;<br />    }<br /><br />    location /auth_webservice {<br />        proxy_pass http://127.0.0.1:6543/auth/webdav;<br />        proxy_pass_request_body off;<br />        proxy_set_header Content-Length "";<br />        proxy_set_header X-Original-URI $request_uri;<br />        proxy_set_header X-Original-Method $request_method;<br />    }<br />    location = /auth_open {<br />        return 204;<br />    }<br />    location / {<br />        uwsgi_pass  unix:///tmp/uwsgi.sock;<br />        include     uwsgi_params;<br />    }<br />}<br /><br />It might be of interest to you to know that even when I change the auth_request to /auth_open, PUT still fails with an HTTP error 500.</p>
<div> </div>
</body></html>