UPD!!!: Issue discussed here is completely solved by this topic:
http://groups.drupal.org/node/155564
And by detailed exploration of:
Nginx configuration by Nginx&Drupal guru - António P. P. Almeida (Perusio).
https://github.com/perusio/drupal-with-nginx
can't solve the following problem: I have FreeBSD, Apache 2.2, PHP (no FastCGI!) as apache module, nginx 0.8.5.4.
I'm trying to move Drupal portal having boost and image_cache enabled on it to personal VPS server.
My goal is to have clean_url rewrites in nginx and correct boost & image_cache rules.
Please help! I know that something's very wrong with my current nginx config. The whole day has been cut on it.
Here is nginx.conf (Only / route works now):
user www www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx-access.log main;
reset_timedout_connection on;
sendfile on;
aio sendfile;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
upstream backend {
# Apache server
server 77.72.19.19:81;
}
server {
listen 77.72.19.19:80 default accept_filter=httpready;
server_name 77.72.19.19;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
gzip on;
gzip_static on;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
set $myroot /usr/local/www/apache22/data/alfa;
root $myroot;
location ~ ^\. {
deny all;
}
set $boost "";
set $boost_query "_";
if ( $request_method = GET ) {
set $boost G;
}
if ($http_cookie !~ "DRUPAL_UID") {
set $boost "${boost}D";
}
if ($query_string = "") {
set $boost "${boost}Q";
}
if ( -f $myroot/cache/normal/$http_host$request_uri$boost_query$query_string.html ) {
set $boost "${boost}F";
}
if ($boost = GDQF){
rewrite ^.*$ /cache/normal/$http_host/$request_uri$boost_query$query_string.html break;
}
if ( -f $myroot/cache/perm/$http_host$request_uri$boost_query$query_string.css ) {
set $boost "${boost}F";
}
if ($boost = GDQF){
rewrite ^.*$ /cache/perm/$http_host/$request_uri$boost_query$query_string.css break;
}
if ( -f $myroot/cache/perm/$http_host$request_uri$boost_query$query_string.js ) {
set $boost "${boost}F";
}
if ($boost = GDQF){
rewrite ^.*$ /cache/perm/$http_host/$request_uri$boost_query$query_string.js break;
}
location ~ ^/sites/.*/files/imagecache/ {
#try_files $uri @rewrite;
error_page 404 = /;
}
location ~* \.(txt|jpg|jpeg|css|js|gif|png|bmp|flv|pdf|ps|doc|mp3|wmv|wma|wav|ogg|mpg|mpeg|mpg4|htm|zip|bz2|rar|xls|docx|avi|djvu|mp4|rtf|ico)$
{
expires max;
add_header Vary Accept-Encoding;
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
proxy_pass "http://backend";
break;
}
}
location ~* \.(html(.gz)?|xml)$ {
add_header Cache-Control no-cache,no-store,must-validate;
root $myroot;
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
proxy_pass "http://backend";
break;
}
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
location / {
proxy_pass http://backend;
}
}
}
UPD: With this nginx.conf I have working /. And any other page gives me: "The page isn't redirecting properly". Who can explain me the order in which location rules are evaluated? And if it is "break" - when nginx meets this line, what it does next. I really tryed about 20 nginx config samples. I don't want one more link, I'd prefer answers of somebody, who has real understanding of what's going on in nginx.conf.
UPD2: If I replace
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
with:
try_files $uri $uri/ @drupal;
location @drupal {
rewrite ^ /index.php?q=$uri last; # for Drupal 6
}
Then all non-root pages give me 404 "The requested URL was not found on this server".