0

I moved my magento store from Server "A" which was on Apache to Server "B" running NginX.

Copied all files and folders, Exported and Imported the SQL DB, Altered the local.xml file with the new DB Details and then ran a DB connection test script which all went fine.

Server "A" is http://hns.lwea.co.uk/ Server "B" is http://hotnstylish.co.uk/

When I navigate to the hotnstylish.co.uk address i get a "Default Magento themed" 404 error: Page Not Found.

Note: I had another magento installation on this nginx instance previously which worked fine :(

NginX Produces the following error logs:

2013/12/01 17:43:43 [error] 5520#0: *105 access forbidden by rule, client: 127.0.0.1,     server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com"
2013/12/01 17:50:38 [error] 5520#0: *108 access forbidden by rule, client: 127.0.0.1,         server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com"
2013/12/01 17:50:40 [error] 5520#0: *111 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com"
2013/12/01 17:50:43 [error] 5520#0: *113 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com"
2013/12/01 17:50:45 [error] 5520#0: *115 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com"
2013/12/01 17:50:48 [error] 5520#0: *117 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com"
2013/12/01 22:50:22 [error] 5520#0: *143 rewrite or internal redirection cycle while processing "/index.php", client: 92.28.188.240, server: 836237.vps-10.com, request: "GET /index.php/admin/cms_page/index/key/a962fe17df7bb966ff6202585abe3f2f/ HTTP/1.1", host: "836237.vps-10.com", referrer: "http://836237.vps-10.com/index.php/admin/mobile/history/key/1e11fb471a8ce41d1f6c6f54368469ba/"
2013/12/01 22:50:51 [error] 5520#0: *145 rewrite or internal redirection cycle while processing "/index.php", client: 95.211.223.32, server: 836237.vps-10.com, request: "POST /cgi-bin/php/%63%67%69%6E/%70%68%70?%2D%64+%61%6C%75%6F%6E+%2D%64+%6D%6F%64+%2D%64+%73%75%68%6F%6E%3D%6F%6E+%2D%64+%75%6E%63%74%73%3D%22%22+%2D%64+%64%6E%65+%2D%64+%61%75%74%6F%5F%70%72%%74+%2D%64+%63%67%69%2E%66%6F%72%63%65%5F%72%65%64%69%72%65%63%74%3D%30+%2D%64+%74%5F%3D%30+%2D%64+%75%74+%2D%6E HTTP/1.1", host: "localhost"
2013/12/01 22:54:02 [error] 5520#0: *146 rewrite or internal redirection cycle while processing "/index.php", client: 23.22.240.96, server: 836237.vps-10.com, request: "HEAD / HTTP/1.1", host: "109.104.94.194"

And the following Access Logs:

92.28.188.240 - - [03/Dec/2013:15:33:35 +0000] "GET /admin HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
92.28.188.240 - - [03/Dec/2013:15:38:47 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
92.28.188.240 - - [03/Dec/2013:15:38:50 +0000] "GET /admin HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
92.28.188.240 - - [03/Dec/2013:15:39:58 +0000] "GET /admin HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
92.28.188.240 - - [03/Dec/2013:15:40:02 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
54.194.106.16 - - [03/Dec/2013:15:43:55 +0000] "GET / HTTP/1.1" 404 1627 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2)"
92.28.188.240 - - [03/Dec/2013:15:48:06 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
92.28.188.240 - - [03/Dec/2013:15:54:30 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
92.28.188.240 - - [03/Dec/2013:15:54:36 +0000] "GET / HTTP/1.1" 404 683 "-" "Mozilla/5.0   (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"

My vHost File is as follows:

server {
listen       80 default_server;
server_name www.hotnstylish.co.uk *.hotnstylish.co.uk; ## Domain is here twice so    server_name_in_redirect will favour the www
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
access_log  /data/www/public_html/hotnstylish/log/access.log;
error_log /data/www/public_html/hotnstylish/log/error.log;
root /data/www/public_html/hotnstylish/public/;

location / {

    include /etc/nginx/mime.types;
    root   /data/www/public_html/hotnstylish/public/;
    index  index.html index.htm index.php; ## Allow a static html file to be shown  first
    try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front  handler
    expires 30d; ## Assume all files are cachable

}

## These locations would be hidden by .htaccess normally
location ^~ /app/                { deny all; }
location ^~ /includes/           { deny all; }
location ^~ /lib/                { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/            { deny all; }
location ^~ /report/config.xml   { deny all; }
location ^~ /var/                { deny all; }  

# media
location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico)$ {
    root   /data/www/public_html/hotnstylish/public/;
    access_log off;
    expires 30d;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
  location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/  { internal; }
  location /var/export/ { internal; }
  location /. { return 404; }
  location @handler { rewrite / /index.php; }
  location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
  #location ~* .php$ {
      #if (!-e $request_filename) { rewrite / /index.php last; }
      #expires off;

location ~ ^(.+\.php)(.*)$ {
root           /data/www/public_html/hotnstylish/public/;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;

}
}

Any clues would be greatly appreciated...

user179181
  • 13
  • 2
  • 5

3 Answers3

1

Here is your problem:

  location @handler { rewrite / /index.php; }

After the rewrite, you go back to location / and back through try_files again. Then it goes back to @handler and you're in an endless loop.

This appears to be totally redundant; just get rid of it and add it directly to try_files.

  try_files $uri $uri/ /index.php;
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
1

It's not an nginx problem.

When accessing the backend, a block notification of security is called.

Look at the class Mage_Adminhtml_Block_Notification_Security:

the "_canShowNotification" function calls another function "_isFileAccessible" which executes a POST to get the file "local.xml".

Jenny D
  • 27,780
  • 21
  • 75
  • 114
-1

The reason it happens is because the default nginx config doesn't support the rewriting needed by Magento. In your nginx configuration file, make sure that you have the following specified under your server config.

location / {
  try_files $uri $uri/ /index.php?q=$uri&$args;
}
Wayne
  • 99
  • 3
  • Please add an actual explanation to your answer rather that just brain-dumping a small snippet of a configuration file. – fukawi2 Dec 12 '14 at 04:29