302 Moved Temporarily для генерируем zip в php
alexitdv
nginx-forum на forum.nginx.org
Вт Авг 22 14:29:08 UTC 2017
Ребята всем привет!
Помогите советом. Уже голова лопается.
Есть друпал на nginx + php-fpm.
Есть в друпале страничка
/admin/store/orders/russian_post/sets/860
На ней формочка и кнопочка экспорт. При ее нажатии генерится zip файлик и
отдается. Только беда, он не скачивается из-за 302.
Ответ
302 Moved Temporarily
Cache-Control: public, must-revalidate
Connection: keep-alive
Content-Disposition: attachment; filename="F007701375635723400003.zip"
Content-Transfer-Encoding: binary
Content-Type: application/x-zip
Date: Tue, 22 Aug 2017 14:16:20 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive: timeout=60
Last-Modified: Tue, 22 Aug 2017 14:16:19 GMT
Location: http://domain/admin/store/orders/russian_post/sets/860
Pragma: public
Server: nginx
Transfer-Encoding: chunked
X-Powered-By: PHP/5.3.27
Конфиг
server {
listen IP:80;
server_name domain.ru m.domain.ru www.domain.ru ddomain.ru
www.ddomain.ru;
root /home/domain/web/domain.ru/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/domain.ru.log combined;
access_log /var/log/nginx/domains/domain.ru.bytes bytes;
error_log /var/log/nginx/domains/domain.ru.error.log error;
#chunked_transfer_encoding off;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
if ($host = 'domain.ru') {
rewrite ^/(.*)$ /robots_domain.txt;
}
if ($host = 'www.ddomain.ru') {
rewrite ^/(.*)$ /robots_ddomain.txt;
}
if ($host = 'ddomain.ru') {
rewrite ^/(.*)$ /robots_ddomain.txt;
}
}
location = /robots_domain.txt {
allow all;
log_not_found off;
access_log off;
}
location = /robots_ddomain.txt {
allow all;
log_not_found off;
access_log off;
}
# Very rarely should these ever be accessed outside of your lan
#location ~* \.(txt|log)$ {
# allow 192.168.0.0/16;
# deny all;
#}
location ~ \..*/.*\.php$ {
return 403;
}
# No no for private
location ~ ^/sites/.*/private/ {
return 403;
}
# Block access to "hidden" files and directories whose names begin with
a
# period. This includes directories used by version control systems
such
# as Subversion or Git to store control files.
location ~ (^|/)\. {
return 403;
}
location / {
try_files $uri @rewrite; # For Drupal <= 6
}
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}
# Don't allow direct access to PHP files in the vendor directory.
location ~ /vendor/.*\.php$ {
deny all;
return 404;
}
location ~ '\.php$|^/update.php' {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
# Security note: If you're running a version of PHP older than the
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
# See http://serverfault.com/q/627903/94922 for details.
include /etc/nginx/fastcgi_params;
# Block httpoxy attacks. See https://httpoxy.org/.
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_pass unix:/opt/php53/var/run/domain.sock;
}
location ~ ^/sites/.*/files/imagecache/ {
try_files $uri @rewrite;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
#error_page 403 /error/404.html;
#error_page 404 /error/404.html;
#error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias /home/domain/web/domain.ru/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/domain/web/domain.ru/stats/;
include /home/domain/web/domain.ru/stats/auth.conf*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/domain/conf/web/nginx.domain.ru.conf*;
}
Posted at Nginx Forum: https://forum.nginx.org/read.php?21,276125,276125#msg-276125
Подробная информация о списке рассылки nginx-ru