DAV + выделение regex + alias

Vadim Lazovskiy vadim.lazovskiy at gmail.com
Mon Apr 28 09:22:08 UTC 2014


Здравствуйте.

Нужно разложить скиншоты по папкам и с таймстампом в имени файла. Вот
конфиг:

server_name s2.domain.example.com;

...

location /s/archive/ {
    location ~
"^/s/archive/screenshots/(?<timestamp>(?<dir>\d{8})\d{4})/(?<basename>\d+).(?<ext>[a-z0-9]+)$"
{

        limit_except GET {
            allow 10.10.1.18;
            deny all;
        }

        dav_methods PUT;
        create_full_put_path on;
        dav_access group:rw all:r;

        alias /disks/screenshots/$dir/$basename-$timestamp.$ext;
        client_body_temp_path /disks/tmp;
    }

...

}

Вот запрос:

10.10.1.18 - - [28/Apr/2014:12:59:12 +0400] "PUT
/s/archive/screenshots/201404281043/0000000142.jpg HTTP/1.1" 201 25 "-"
"curl/7.26.0"

Вот фрагмент debug-лога:

2014/04/28 12:59:12 [debug] 5297#0: *404 http run request:
"/s/archive/screenshots/201404281043/0000000142.jpg?"
2014/04/28 12:59:12 [debug] 5297#0: *404 http read client request body
2014/04/28 12:59:12 [debug] 5297#0: *404 recv: fd:17 3592 of 3592
2014/04/28 12:59:12 [debug] 5297#0: *404 http client request body recv 3592
2014/04/28 12:59:12 [debug] 5297#0: *404 http body new buf t:1 f:0
0000000001EC7E00, pos 0000000001EC7E00, size: 5200 file: 0, size: 0
2014/04/28 12:59:12 [debug] 5297#0: *404 http client request body rest 0
2014/04/28 12:59:12 [debug] 5297#0: *404 event timer del: 17: 1398675612105
2014/04/28 12:59:12 [debug] 5297#0: *404 http write client request body,
bufs 0000000001EBF818
2014/04/28 12:59:12 [debug] 5297#0: *404 write: 19, 0000000001EC7E00, 5200,
98304
2014/04/28 12:59:12 [debug] 5297#0: *404 http script copy:
"/disks/screenshots/"
2014/04/28 12:59:12 [debug] 5297#0: *404 http script var: "20140428"
2014/04/28 12:59:12 [debug] 5297#0: *404 http script copy: "/"
2014/04/28 12:59:12 [debug] 5297#0: *404 http script var: "0000000142"
2014/04/28 12:59:12 [debug] 5297#0: *404 http script copy: "-"
2014/04/28 12:59:12 [debug] 5297#0: *404 http script var: "201404281043"
2014/04/28 12:59:12 [debug] 5297#0: *404 http script copy: "."
2014/04/28 12:59:12 [debug] 5297#0: *404 http script var: "jpg"
2014/04/28 12:59:12 [debug] 5297#0: *404 http put filename:
"/disks/screenshots/20140428/
0000000142-201404281043.jpgs2.domain.example.com"
2014/04/28 12:59:12 [debug] 5297#0: *404 HTTP/1.1 201 Created
Server: nginx/1.7.0
Date: Mon, 28 Apr 2014 08:59:12 GMT
Content-Length: 0
Location:
http://s2.domain.example.com/s/archive/screenshots/201404281043/0000000142.jpg
Connection: keep-alive

Ну и результат:

# find /disks/screenshots/
/disks/screenshots/
/disks/screenshots/20140428
/disks/screenshots/20140428/0000000142-201404281043.jpgs2.domain.example.com

Версия:

# /usr/sbin/nginx.debug -V
nginx version: nginx/1.7.0
built by gcc 4.7.2 (Debian 4.7.2-5)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx
--with-http_ssl_module --with-http_realip_module
--with-http_addition_module --with-http_sub_module --with-http_dav_module
--with-http_flv_module --with-http_mp4_module --with-http_gunzip_module
--with-http_gzip_static_module --with-http_random_index_module
--with-http_secure_link_module --with-http_stub_status_module
--with-http_auth_request_module --with-mail --with-mail_ssl_module
--with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2
-fstack-protector --param=ssp-buffer-size=4 -Wformat
-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6 --with-debug

Вопрос. Откуда берется домен в имени файла и как это побороть?

Спасибо!

-- 
Best Regards,
Vadim Lazovskiy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-ru/attachments/20140428/bdc899fb/attachment.html>


Подробная информация о списке рассылки nginx-ru