Welcome! Log In Create A New Profile

Advanced

Re: Directory fallback

merlin corey
December 29, 2009 04:24PM
On Tue, Dec 29, 2009 at 9:56 AM, Tobia Conforto
<tobia.conforto@gmail.com> wrote:
> Hello
>
> I'm trying to come up with a nginx configuration file for a fallback-like directory structure.
>
> I have the following directories:
> /var/www/base/ (generic files)
> /var/www/site1/ (files specific to site1)
>
> Given a request for /logo.png, I would like nginx to do the following:
> 1. serve /var/www/site1/logo.png if exists; otherwise
> 2. serve /var/www/base/logo.png.
>
> The matter is complicated by the presence of PHP files. Given a request for /index.php (possibly in the same directory as image files...) nginx should:
> 1. serve /var/www/site1/index.php through FastCGI, if the php file exists; otherwise
> 2. serve /var/www/base/index.php through FastCGI.
>
> Can anybody please suggest the optimal combination of document_root, alias, location, rewrite, try_files or such options to use? I would like to avoid client-side redirects. Everything else is ok.
>
> Tobia
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

Make an attempt at least! :-)

I'll get you started... please note this is written for 0.8.30 and
above and I didn't test this, but it should be close.

upstream php {
server 127.0.0.1:9000;
}

server {
listen 80;
server_name site1;
root /var/www/site1;
fastcgi_intercept_errors on;
location / {
try_files $uri /var/www/base$uri;
}
location ~ \.php {
error_page 404 = @basephp
include fastcgi.conf;
fastcgi_pass php;
}
location @basephp {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/base$fastcgi_script_name;
fastcgi_pass php;
}
}

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Directory fallback

Tobia Conforto December 29, 2009 01:00PM

Re: Directory fallback

merlin corey December 29, 2009 04:24PM

Re: Directory fallback

Tobia Conforto December 29, 2009 06:32PM

Re: Directory fallback

merlin corey December 30, 2009 02:32AM

Re: Directory fallback

Tobia Conforto December 30, 2009 06:46AM

Re: Directory fallback

merlin corey January 07, 2010 01:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 98
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready