Welcome! Log In Create A New Profile

Advanced

Drupal + nginx + Apache: try_files вызывает циклический редирект

July 24, 2012 02:46PM
Здравствуйте. Столкнулся с проблемой конфигурации nginx у себя на сервере под Drupal 6. После установки nginx в связке с Apache, перестал работать модуль Imagecache по генерации различных версий картинок, загружаемых на сайте. Много всего вычитал в сети на эту тему и выяснил, что в локейшенах стоит прописать директиву try_files, чтобы в случае, если файл не обнаружен, запрос передавался на обработку Апачу, и тогда модуль Imagecache должен сделать свое дело по генерации файла.

Я делал все в частности как указано в вики: http://wiki.nginx.org/HttpCoreModule#try_files за исключением того, что у меня fastcgi не стоит. Но в итоге, в каком бы я локейшене не прописывал "try_files $uri $uri/ /index.php?q=$uri;" по его адресу происходит циклическое перенаправление, о чем любезно сообщил мне Хром (Опера же тупо белую страницу выдает).

Прошу помощи в настройке nginx, т.к. уже больше месяца не могу решить эту проблему, которая стопорит всю работу над сайтом.

========================================
Вот так выглядит nginx.conf:
========================================
user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
access_log /var/log/nginx/access.log;
gzip_comp_level 5;
gzip_types text/xml application/xml application/x-javascript text/javascript text/css text/json;
gzip_disable "msie6";
output_buffers 1 32k;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
========================================

========================================
Вот так выглядит отдельный конфиг из sites-available - mysite.com:
========================================
server {

listen mysite.com:80;
server_name mysite.com www.mysite.com dev.mysite.com download.mysite.com www.mysite.com download.myoldsite.com www.myoldsite.com www.download.myoldsite.com;
root /var/www/mysite/;
index index.php index.html index.htm;
charset utf-8;
access_log /var/log/nginx/access_mysite.log;
error_log /var/log/nginx/error_mysite.log warn;

if ( $host = myoldsite.com ) {
rewrite ^(.*) http://mysite.com$1 permanent;
}
if ( $host = www.myoldsite.com ) {
rewrite ^(.*) http://mysite.com$1 permanent;
}
if ( $host = www.download.mysite.com ) {
rewrite ^(.*) http://download.mysite.com$1 permanent;
}
if ( $host = www.myoldsite.com ) {
rewrite ^(.*) http://download.myoldsite.com$1 permanent;
}


if ($host !~ ^(mysite.com|www.mysite.com|download.myoldsite.com|www.download.myoldsite.com|dev.mysite.com|www.dev.mysite.com)$) {
rewrite ^(.*) http://mysite.com$1 permanent;
}

location / {
proxy_pass http://127.0.0.1:81/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;#
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
client_body_temp_path /var/nginx/client_body_temp 1 2;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_temp_path /var/nginx/proxy_temp 1 2;

try_files $uri $uri/ /index.php?q=$uri;
}

# Serve static files directly by nginx
location ^~ /files/ {
access_log off;
expires 20d;
try_files $uri $uri/ /index.php?q=$uri;
}
location ~* ^.+\.(jpeg|jpg|gif|png|bmp|ico|swf|exe|air|ttf|otf|xml|torrent|bup|ifo|info|nfo|cur|tar|zip|tgz|rar|bz2|pdf|psd|txt|doc|xls|docx|xlsx|bak|veg|sfk|css|js|ogg|mp3|ac3|flac|mp2|wav|wma|wmv|avi|mpeg|mpg|mov|flv|mp4|webm|mkv|ts|vob|m4v|rm|m2ts|mts)$ {
access_log off;
expires 30d;
try_files $uri $uri/ /index.php?q=$uri;
}

# Deny access to .htaccess files, if Apache's document root concurs with nginx's one
location ~ /\.ht {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}

# Deny access to unix backup files
location ~* \~$ {
deny all;
}

# Set error page handle by Drupal
error_page 500 502 503 504 /error50x.html;
location = /error50x.html {
root /var/www/mysite/;
}
error_page 404 /error404.html;
location = /error404.html {
root /var/www/mysite/;
}

# Deny access to system files and directories
location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
deny all;
}
location ~ "^/(CHANGELOG|COPYRIGHT|INSTALL\.mysql|INSTALL\.pgsql|INSTALL|LICENSE|MAINTAINERS|UPGRADE)\.txt" {
deny all;
}

location ^~ /files/imagecache/ {
root /var/www/mysite;
index index.php index.html;
try_files $uri $uri/ /index.php?q=$uri;
}
}
========================================

Может кто-то сможет подсказать в чем ошибка? При данной конфигурации с указанием try_files $uri $uri/ /index.php?q=$uri; по соответствующим локейшенам происходит циклический редирект, в том числе на всех внутренних страницах сайта.

Заранее благодарен за помощь.
Subject Author Posted

Drupal + nginx + Apache: try_files вызывает циклический редирект

STINGER_LP July 24, 2012 02:46PM

Re: Drupal + nginx + Apache: try files вызывает циклический редирект

Pavel V. July 25, 2012 05:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 195
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready