I\'m trying to serve request to /blog subdirectory of a site with the php code, located in a folder outside document root directory. Here\'s my host config:
There is another workaround which gives more flexibility. It consists of a proxy_pass directive which points on 127.0.0.1 and another server block.
In your case it should looks like this:
upstream blog.fake {
server 127.0.0.1;
}
server {
server_name local.test.ru;
root /home/alex/www/test2;
index index.html;
location /blog {
proxy_pass http://blog.fake/;
}
}
server {
server_name blog.fake;
root /home/alex/www/test1;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}