Nginx config can not get the rewrite right on EC2. Message "The requested page "/" could not be found."

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
dutgriff33's picture

I have been working on this for a few days now and I can not get it to work. I am having the same error after every install on my amazon EC2. I have done the exact steps as on my local machine and it will not work for me on my EC2 server. I am getting to the end of the installation right after it asks for the databases info and it goes to a page saying "Page not found. The requested page "/" could not be found." this is being displayed in the Drupal default theme so it is working. If you are reading this before I get it fixed check out dutgriff.com to see what it is displaying. My setup is Ubuntu 12.04 LTS on Amazon EC2 running Nginxm PHP5-fpm and MySQL. I am almost sure it is my rewrite because it will display the message on every page. Before the Drupal install on my previous trial I made a phpinfo file and was unable to get to it from dutgriff.com/info.php but when I changed the name to index.php I was able to access it at dutgriff.com and dutgriff.com/(anything). So everything is getting directed to dutgriff.com/. Here it my /etv/nginx/sites-available/default:

server {
  listen 80 default_server;
  access_log /var/log/nginx/dutgriff-com.access.log;
  error_log  /var/log/nginx/dutgriff-com.error.log;
  root /var/www/dutgriff-com;
  server_name _;

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  # This matters if you use drush
  location = /backup {
    deny all;
  }

  # 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;
  }

  location / {
    # This is cool because no php is touched for static content
    try_files $uri @rewrite;
  }

  location @rewrite {
    # Some modules enforce no slash (/) at the end of the URL
    # Else this rewrite block wouldn't be needed (GlobalRedirect)
    rewrite ^/(.*)$ /index.php?q=$1;
  }

  location ~ .php$ {
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9000;
  }

  #Fighting with ImageCache? This little gem is amazing.
  location ~ ^/sites/.*/files/styles/ {
    try_files $uri @rewrite;
  }

    location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
  }
}

Any help is appreciated. I am willing to try anything. Thanks ahead of time.

Comments

Did you found solution to

jahmal's picture

Did you found solution to this? I have exact the same problem on ec2

I presume from the file path

Garrett Albright's picture

I presume from the file path that you're using Perusio's config, right? If so, you should have created a dutgriff.com.conf file in the sites-available directory, right?

If not, you're not going to get very far. Try reading the readme at the root level of the config directory or on the Github project page.