montreyw / Theme-Redesign-and-SEO-Overhaul

Earmilk redesign project
2 stars 0 forks source link

Navigating to `/SQLiteManager-1.2.4/main.php ` (or `/administrator/index.php`, *.php, etc) leads to "File not found" -- "FastCGI sent in stderr: "Primary script unknown"" #43

Closed andrebu closed 8 years ago

andrebu commented 8 years ago

Navigating to /SQLiteManager-1.2.4/main.php (or /administrator/index.php, *.php, etc) leads to "File not found" -- "FastCGI sent in stderr: "Primary script unknown""

I suspect incorrect Nginx settings.


Other deets:

016/03/08 01:26:22 [error] 659#659: *2738 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 198.245.55.221, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "earmilk.com" Know what that might mean?

Someone tried to access http://earmilk.com/SQLiteManager-1.2.4/main.php That file doesn't exist => error.

http://earmilk.com/administrator/index.php That yielded error: 2016/03/08 09:04:37 [error] 670#670: *184594 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 47.20.3.104, server: earmilk.com, request: "GET /administrator/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "earmilk.com"

Going to http://earmilk.com/administrator/indexss.php yields: 2016/03/08 09:04:46 [error] 670#670: *184594 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 47.20.3.104, server: earmilk.com, request: "GET /administrator/indexss.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "earmilk.com"

screen shot 2016-03-08 at 12 05 19 pm screen shot 2016-03-08 at 12 05 22 pm screen shot 2016-03-08 at 12 05 25 pm screen shot 2016-03-08 at 3 54 00 pm
andrebu commented 8 years ago

A lot of good info on the changes I made https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/

About root specifically -- https://www.nginx.com/resources/admin-guide/serving-static-content/

Going to change it from this: -- File: earmilk.com.conf

server {
    listen       192.168.102.1:80;
    server_name  www.earmilk.com;
    return       301 $scheme://earmilk.com$request_uri;
    rewrite_log  on;
}

server {
    listen       192.168.102.1:80;
    server_name  earmilk.com mulwray.earmilk.com;
    charset utf-8;
    root   /home/www-data/earmilk/public;

    rewrite_log on;
    error_log /var/log/nginx/earmilk.com.error.log;
    access_log  /var/log/nginx/earmilk.com.access.log;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
        try_files $uri $uri/ /index.php?$args;
        index  index.php index.html index.htm;
        autoindex on;

        # Add trailing slash to */wp-admin requests.
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;

        # Include W3TC's editable nginx.conf file in WordPress root
        # include /home/www-data/earmilk/public/nginx.conf;

        location ~* \.(png|gif|jpg|jpeg)$ {
            error_page 404 http://images.earmilk.com/delivery.png;
            proxy_read_timeout 300;
            fastcgi_read_timeout 300s;
        }

    }

    location /sxsw-2015 {
        root /home/www-data/earmilk/public/microsites/sxsw-2015;
    }

    location ~ \.php$ {
       root /home/www-data/earmilk/public;
       fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    proxy_read_timeout 300s;
        fastcgi_read_timeout 300s;
        fastcgi_buffers 16 16k; 
        fastcgi_buffer_size 32k;
    }

    #
    #  Error Handling
    #
    error_page  404 /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # Security

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
    # Block PHP files in uploads directory.
    location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
    }

    # Block PHP files in content directory.
    location ~* /wp-content/.*\.php$ {
    deny all;
    }

    # Block PHP files in includes directory.
    location ~* /wp-includes/.*\.php$ {
    deny all;
    }

    # Block PHP files in uploads, content, and includes directory.
    location ~* /(?:uploads|files|wp-content|wp-includes)/.*\.php$ {
    deny all;
    }

}

to this:

server {
    listen   192.168.102.1:80;
    server_name  www.earmilk.com;
    return   301 $scheme://earmilk.com$request_uri;
    rewrite_log  on;
}

server {
    listen   192.168.102.1:80;
    server_name  earmilk.com mulwray.earmilk.com;
    charset utf-8;

    rewrite_log off;
    error_log   /var/log/nginx/earmilk.com.error.log;
    access_log  /var/log/nginx/earmilk.com.access.log;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
        try_files $uri $uri/ /index.php?$args;
        root   /home/www-data/earmilk/public;
        index  index.php index.html index.htm;
        autoindex on;

        # Add trailing slash to */wp-admin requests.
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;

        # Include W3TC's editable nginx.conf file in WordPress root
        # include /home/www-data/earmilk/public/nginx.conf;

        location ~ \.php$ {
            include        fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            proxy_read_timeout 300s;
            fastcgi_read_timeout 300s;
            fastcgi_buffers 16 16k;
            fastcgi_buffer_size 32k;
        }

    location ~* \.(png|gif|jpg|jpeg)$ {
            error_page 404 http://images.earmilk.com/delivery.png;
screen shot 2016-03-08 at 4 14 50 pm screen shot 2016-03-08 at 4 15 04 pm screen shot 2016-03-08 at 4 18 14 pm
andrebu commented 8 years ago

Adding try_files $uri =404; to right above include fastcgi_params

New error upon trying a nonexistent *.php file.

2016/03/08 13:29:13 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"

2016/03/08 13:29:15 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"

2016/03/08 13:29:17 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"

2016/03/08 13:29:17 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"