Behavior of server depends on a file name

Dave Cheney dave at cheney.net
Fri Sep 12 13:15:08 MSD 2008


The default site for a listener is the site marked

server {
	listen 80 default;
}

if no servers are marked default then the first server defined (which  
depends on the order that include /*.conf is evaluated) will be the  
default server.

I get around this problem by defining a site called default.conf which  
includes the listen 80 default; stanza.

Cheers

Dave

On 12/09/2008, at 6:59 PM, Gregor Jurgele wrote:

> Hello
>
> I would like to run a few virtual sites on one IP on nginx 0.6.32  
> compiled from source as Debian package on Debian Etch.
>
> My nginx.conf contents are:
>
> user www-data;
> worker_processes  1;
>
> error_log  /var/log/nginx/error.log;
> pid        /var/run/nginx.pid;
>
> events {
>     worker_connections  1024;
> }
>
> http {
>     include       /etc/nginx/mime.types;
>     default_type  application/octet-stream;
>
>     access_log  /var/log/nginx/access.log;
>
>     sendfile        on;
>     #tcp_nopush     on;
>
>     #keepalive_timeout  0;
>     keepalive_timeout  65;
>     tcp_nodelay        on;
>
>     gzip  on;
>
>     server_tokens     off;
>
>     include /etc/nginx/conf.d/*.conf;
>     include /etc/nginx/sites-enabled/*;
> }
>
> My virtual site file (www.bona-a.com) contents are:
>
> server {
>         listen   80;
>         server_name  www.bona-a.com;
>
>         access_log  /var/log/nginx/www.bona-a.com.access.log;
>
>         location / {
>                 root   /var/www/www.bona-a.com;
>                 index  default.html default.htm index.html index.htm;
>         }
>
>         # pass the PHP scripts to FastCGI server listening on  
> 127.0.0.1:9000
>         #
>         #location ~ \.php$ {
>                 #fastcgi_pass   127.0.0.1:9000;
>                 #fastcgi_index  index.php;
>                 #fastcgi_param  SCRIPT_FILENAME  /scripts 
> $fastcgi_script_name;
>                 #includefastcgi_params;
>         #}
> }
>
> If I name a file or symbolic link in /etc/nginx/sites-enabled/, that  
> holds the information for a virtual site, www.bona-a.com, this site  
> becomes a catch-all site, answering all requests that go to the same  
> ip and do not match any of the sites defined in other files in /etc/ 
> nginx/sites-enabled/.
>
> Same is if I replace -a with - followed by any letter between b and  
> d (including). If I name the file www.bona-e.com or www.bona.com,  
> everything works fine and i get 403 Forbidden as a reply.
>
> What am I doing wrong?
>
> Regards,
>
> Gregor





More information about the nginx mailing list