Wordpress on a subdirectory with Nginx using a proxy server without input file error

Hope you can help, but I get the error below when trying to access the administration section of the blog.

No input file specified.

The actual blog is working fine, but not the login / administration area.

According to the title, a blog on a separate server is the main domain and uses a proxy server to forward requests to it like this.

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 that I have on the blog server are 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, for example, fastcgi_params if that helps.

 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 ""; 

As far as I understand, I believe that PHP can not find the index.php file?

Hope someone can help.

+6
source share
3 answers

The reason is that the upstream did not allow any other parameters, i.e. the .php extension, it was an upstream location change.

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

Hope this helps someone else in the future.

0
source

You should specify only index index.php; .

You must also change location / { try_files $uri $uri/ /blog/index.php?$query_string; } location / { try_files $uri $uri/ /blog/index.php?$query_string; } at location / { try_files $uri $uri/ /blog/index.php?$args; } 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;

in

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

This comes from the WordPress documentation as well as the NGINX documentation .

+1
source

maybe rewrite the / blog path to abort the prefix?

 server{ ... location /blog { #strip the '/blog' prefix rewrite /blog/(.*) /$1 break; 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; } } 
0
source

Source: https://habr.com/ru/post/1014155/


All Articles