By beaudierman
I’m trying to set up a proxy to my Wordpress blog using proxy_pass but I’m getting some very strange behavior. My Wordpress blog is located at blog.example.com/blog/ and the website at www.example.com, I’d like the blog to appear at www.example.com/blog/. Here’s the code I have, which works for viewing the blog but not for any PHP scripts(logging in, wp-cron, etc all results in “No Input File Specified” error) on the blog:
location /blog/ {
expires off;
proxy_pass http://blog.example.com/blog/;
}
Here is the output in my nginx error log when trying to access the wp-admin page:
2015/02/08 14:28:33 [error] 20572#0: *594485 FastCGI sent in stderr: "Unable to open primary script: /home/user/www.example.com/public/blog/wp-login.php (No such file or directory)" while reading response header from upstream, client: 10.0.1.214, server: www.example.com, request: "GET /blog/wp-login.php?redirect_to=http%3A%2F%2Fblog.example.com%2Fblog%2Fwp-admin%2F&reauth=1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.example.com"
It appears that any PHP script is hitting my .php block:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
Any help is greatly appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @moncefhammou:
@beaudierman I actually fixed it with this. Don’t know if it’s the best way to do it tho. Thanks for you help btw :)
location ~* ^((?!\/blog)(.+)\.php)$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.