how to handle "server_name" in intranet environment

Igor Sysoev is at rambler-co.ru
Fri Sep 7 08:44:30 MSD 2007


On Thu, Sep 06, 2007 at 11:49:18PM +0000, Bert Douglas wrote:

> Igor Sysoev <is at ...> writes:
> 
> > On Thu, Sep 06, 2007 at 07:27:48PM +0000, Bert Douglas wrote:
>  
> > > What should I put in for "server_name"?
> > > 
> 
> > 
> > Try
> >       server_name  _ *;
> > 
> > the "_" is stub, and "*" says nginx to use client "Host" header.
> >
> 
> Sadly, it doesn't seem to work.
> 
> Request to http://192.168.x.x/abc
> 
> server_name _ *;
> 
> location /abc/ {
> ...
> } 
> 
> This gets redirected to:
> http://_/abc/
> Which is a problem.
> 
> Client sends "host" header as follows:
> Host: 192.168.2.92:8811
> So it is not blank.

I forgot about optimize_server_names - by default if there is single
virtual host on given ip:port pair then nginx do not use server_name at all:

    server {
        server_name _ *;
        optimize_server_names off;

But if request will be without "Host" header then nginx will return
http://_/abc/.

If you do not set server_name at all, then nginx will use hostname.
If your system set hostname to IP address it will work for for you.


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





More information about the nginx mailing list