Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress on Sub Directory with Nginx using Proxy Pass with No Input File error

Hope you can help but I am getting error below when trying to access the admin section of are blog.

No input file specified.

The actual blog is working fine but not the login/admin areas.

As per the title the blog is on a seperate server to are main domain and were using proxy pass to forward requests to it like so.

upstream blog {
    server 111.111.111.111:443 weight=2 max_fails=3 fail_timeout=60s;
}

server{
  ...
  location /blog {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass https://blog;
    }
}

The nginx settings I have on the blog server is as follows.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.domain.com;
    root /home/www.domain.com/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /blog/index.php?$query_string;
    }

    error_log  /var/log/nginx/www.domain.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

}

Here are the fastcgi_params if it helps as well.

fastcgi_param   QUERY_STRING        $query_string;
fastcgi_param   REQUEST_METHOD      $request_method;
fastcgi_param   CONTENT_TYPE        $content_type;
fastcgi_param   CONTENT_LENGTH      $content_length;
fastcgi_param   SCRIPT_FILENAME     $request_filename;
fastcgi_param   SCRIPT_NAME     $fastcgi_script_name;
fastcgi_param   REQUEST_URI     $request_uri;
fastcgi_param   DOCUMENT_URI        $document_uri;
fastcgi_param   DOCUMENT_ROOT       $document_root;
fastcgi_param   SERVER_PROTOCOL     $server_protocol;
fastcgi_param   GATEWAY_INTERFACE   CGI/1.1;
fastcgi_param   SERVER_SOFTWARE     nginx/$nginx_version;
fastcgi_param   REMOTE_ADDR     $remote_addr;
fastcgi_param   REMOTE_PORT     $remote_port;
fastcgi_param   SERVER_ADDR     $server_addr;
fastcgi_param   SERVER_PORT     $server_port;
fastcgi_param   SERVER_NAME     $server_name;
fastcgi_param   HTTPS           $https if_not_empty;
fastcgi_param   REDIRECT_STATUS     200;
fastcgi_param   HTTP_PROXY  "";

I understand I believe that PHP cant find the index.php file?

Hope someone can help..

like image 225
Lee Avatar asked Jan 17 '17 15:01

Lee


1 Answers

You should be able to specify just index index.php;.

You should also change

location / { try_files $uri $uri/ /blog/index.php?$query_string; }

to

location / { try_files $uri $uri/ /blog/index.php?$args; }

and change:

fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;

to:

fastcgi_split_path_info ^(/blog)(/.*)$;
fastcgi_pass php;

This is coming from the WordPress documentation as well as the NGINX documentation.

like image 119
Kinna T Avatar answered Oct 20 '22 10:10

Kinna T