Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

While migrating a site from another server, some strange problem occured. I use the default configuration for all my drupal sites, but this one doesnt seem to work. Some image files cause an internal server error - rewrite or internal redirection cycle. The site does not have a domain, yet, so I am testing with the server ip, which should not be a problem. When using this configuration for some default drupal installation, everything works fine. I also use memcached for static file caching, you can see that. As already mentioned, all of this should work properly.

This is my configuration:

server {
 server_name SERVERIP;
 root /var/www/;
 listen 80;
 listen [::]:80;
 index index.php;
 access_log /var/log/nginx/SERVERIP.access.log;
 error_log /var/log/nginx/SERVERIP.error.log;

 if (-f $request_filename) {
 break;
 }

 # memcached
 location ~* \.(jpg|png|gif|js)$ {
 access_log off;
 expires max;
 set $memcached_key $uri;
 memcached_pass memcached;
 error_page 404 = @domain;
 }

 location / {
 try_files $uri $uri/ @domain;
}

 location ~* ^.+.(htm|html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
 access_log off;
 expires max;
 root /var/www/;
 }

 location @domain {
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_param SCRIPT_FILENAME $document_root/index.php;
 include /etc/nginx/fastcgi_params;
 fastcgi_param SCRIPT_NAME /index.php;
 }

 location ~ \.php$ {
 try_files $uri $uri/ @domain;
 fastcgi_index index.php;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include /etc/nginx/fastcgi_params;
 }
 }

I would be very glad if anyone could help me out. Thanks in advance.

regards

share|improve this question
    
Is your memcache working right? –  Christopher Perrin Sep 26 '12 at 18:12
    
yes, it is. Even when I comment out these lines and let the server fetch each file normally, it doesnt work. –  s1ck Sep 26 '12 at 18:16
    
I think I got the confusing bit. When looking at the requests, some requests are sent as SERVERIP/sites/all/.../file.jpg and not like SERVERIP/SITEFOLDER/sites/all/.../file.jpg –  s1ck Sep 26 '12 at 18:18

1 Answer 1

up vote 0 down vote accepted

It turns out, that, when using a domain name for the site, everything works correctly. Maybe, the document root was just not set correctly or I messed something else up. Also, some strange URL rewrites were active, which I had to turn off.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.