server_name & redirect

Igor Sysoev is at rambler-co.ru
Fri Jul 25 20:24:31 MSD 2008


On Fri, Jul 25, 2008 at 06:21:31PM +0200, Christophe de Kerviler wrote:

> I would like to have multiple domains on nginx to manage images. If one 
> image is not available, I redirect to a php processing the image. On the 
> next call the image will be available.
> 
> My conf looks like this:
> 
> server {
>        listen       80;
>        server_name img.domain1.com img.domain2.com img.domain3.com
> .....
> 
> and this something like this:
> 
> if (! -f  $myimagefile) {
>  
>    rewrite /process.php?param=some_parameters redirect;
>    break;
> }
> 
> My problem is if I call img.domain2.com and if the image is not there, 
> I'am redirected to img.domain1.com/process.php...
> instead of domain2.com/process.php
> 
> The first domaine behind "server_name". Is there a solution for that, or 
> a work around?

If you use 0.6.25+, then you need to set

   server_name_in_redirect  off;


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list