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

I have the following simple server block on NGINX:

    server {
        listen 80;
        listen 8090;
        server_name domain.com;
        autoindex on;

        root /home/docroot;

        location ~ \.php$ {
            include /usr/local/nginx/conf/fastcgi_params;       
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /home/docroot$fastcgi_script_name;
            fastcgi_pass   127.0.0.1:9000;
        }
    }

After I include the relevant settings on my hosts file I get the following (unexpected) behavior:

  1. http: //domain.com/ and http: //domain.com:8090/ work fine;
  2. http: //domain.com:8090/future-cell-phone-technology-01-150x150.jpg works;
  3. http: //domain.com/future-cell-phone-technology-01-150x150.jpg -> ERROR! "The connection was reset"

(note.- added a space after http: to avoid link protection but this is not really promoting anything)

I've been troubleshooting (3) for a couple hours and I'm unable to identify the culprit. I'm running NGINX 1.0.10 (latest stable) on Debian 6.0.2 32 bits.

This NGINX instance runs another 40 or 50 sites with no problems.

share|improve this question
    
BTW, http: //st.rdsx.net/info.php and http: //st.rdsx.net:8090/info.php also work! (both) –  Unai Nov 29 '11 at 3:25
    
Insert an error_log directive, turning on the level to debug, try with different browser and take a look at the log file. –  quanta Dec 1 '11 at 8:42

1 Answer 1

Perhaps you need to use try_files directive, as it seems that you have a problem serving static files (.jpg and possibly other graphics, css, etc.) but not php files.

An example configuration for drupal from NGginx wiki:

# for Drupal 6 or 7:
try_files $uri $uri/ /index.php?q=$uri&$args;

# a better version for Drupal 7 since it doesn't need q=$uri:
try_files $uri $uri/ /index.php?$args;

location ~ \.php$ {
  fastcgi_pass 127.0.0.1:8888;
  fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name; # if not already     defined in the fastcgi_params file
  # any other specific fastcgi_params
}

For more details see: http://wiki.nginx.org/HttpCoreModule#try_files

So given your configuration perhaps simply adding try_files directive would work like this (not tested)?:

server {
    listen 80;
    listen 8090;
    server_name domain.com;
    autoindex on;

    root /home/docroot;

    try_files $uri $uri/ /index.php?$args;

    location ~ \.php$ {
        include /usr/local/nginx/conf/fastcgi_params;       
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/docroot$fastcgi_script_name;
        fastcgi_pass   127.0.0.1:9000;
    }
}
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.