Opened 11 years ago

Closed 11 years ago

#298 closed enhancement (wontfix)

Support X-accel-redirect with webdav PUT

Reported by: David Butler Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc: croepha@…
uname -a: Linux 3.2.0-36-generic-pae #57-Ubuntu SMP Tue Jan 8 22:01:06 UTC 2013 i686 i686 i386 GNU/Linux
nginx -V:
nginx version: nginx/1.1.19
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/ --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-dav-ext-module


To reproduce:

nginx.conf excerpt:

location /tmp/ {

alias /tmp/;
autoindex on;
dav_methods PUT;


location /test/ {

proxy_pass http://localhost:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_request_body off;
proxy_set_header Content-Length 0;


on a console:
socat TCP-LISTEN:8000,reuseaddr,crlf stdio

chrome console:
var xhr = new XMLHttpRequest()"put", "http://<scrubbed>/test/1234")

PUT /test/1234 HTTP/1.0
X-Real-IP: <scrubbed>
Content-Length: 0
Host: localhost:8000
Connection: close
Cache-Control: no-cache
Pragma: no-cache
Origin: http://<scrubbed>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
Content-Type: application/xml
Accept: */*
Referer: http://<scrubbed>/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

HTTP/1.0 200
X-Accel-Redirect: /tmp/asdf


2013/02/13 20:08:12 [error] 1494#0: *12474 open() "/tmp/asdf" failed (2: No such file or directory), client:, server: , request: "PUT /test/1234 HTTP/1.1", upstream: "", host: "<scrubbed>, referrer: "<scrubbed>"

If I try to do a PUT request directly, it creates the file...

Change History (2)

comment:1 by David Butler, 11 years ago

By the way, a hack to get around this is to do something like this:

location /tmp/ {

deny all;
alias /tmp/;
dav_methods PUT;

location /tmp_proxy/ {

proxy_pass http://localhost:80/tmp/;


and then pass /tmp_proxy/... to X-Accel-Redirect

Now you can use Nginx for downloads as well as uploads! and the application only handles the auth and management

comment:2 by Maxim Dounin, 11 years ago

Resolution: wontfix
Status: newclosed

As of nginx 1.5.4, the auth request module is available out of the box to do such things with less effort.

Note: See TracTickets for help on using tickets.