ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: nginx-ru@xxxxxxxxx
  • Subject: DAV + выделение regex + alias
  • From: Vadim Lazovskiy <vadim.lazovskiy@xxxxxxxxx>
  • Date: Mon, 28 Apr 2014 13:22:08 +0400
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=TAOL1CCpb6Kp5TUnLpsFGQhObeoPilegyNWZ9OlgbiY=; b=oIznhJE2hF0+EQcJdBouoTzCXsrUN4g7YsUoRLyHv9Souazjucx7AVi6pwA1YV3bF0 JjbFmmX9iPFSB/xrJa22hiywIwyJ5Pt12Tjp7Yy6H9A3cRlXgmLSgmLGWwC4PKVQ9JZR rZRNDhlGwVDhWqkOH6/XBoUhFgeFUuwdnrVa9/P9kenly76kozdKYj136TKv6dq3Ip5C ZqMtYdNXzdaC/4pmVdzqV138d3GRJZvS0L//ylaPeC0Lw7fdUcoD8yG82GGRG1O4BW/D DHX6YLEq++Vy1zmYYP+Hu+xM2vgq/+auvq3KzOp5HrJUt54lLFEFjIu6/A4YAkaiPTIM vmqg==

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

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


...

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
Connection: keep-alive

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

# find /disks/screenshots/
/disks/screenshots/
/disks/screenshots/20140428

Версия:

# /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
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru


 




Copyright © Lexa Software, 1996-2009.