Conflicting server name - i don't understand

ktm nginx-forum at nginx.us
Wed Sep 2 01:51:19 MSD 2009


This is my vhost file.Basically for every vhost i just copy this and change domain name. What i'm missing here, why if i add the second vhost it gives me that error ?



 server {
            listen   80;
            server_name  www.xxx.com;
			
			#redirect www to non-www
            rewrite ^/(.*) http://xxx.com/$1 permanent;
            
			
       }


server {
			listen   80;
			server_name xxx.com;
            access_log /home/xxx/log/access.log;
            error_log /home/xxx/log/error.log;
			
			
			
            location /  {
				root   /home/xxx/public_html/;
				index  index.php index.html;      
				expires 30d;
						
				#stop image and files hotlinking
				location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|jpeg|css)$ {
				valid_referers none blocked xxx.com www.xxx.com *.google.com *.yahoo.com;
				if ($invalid_referer) {
				return 444;
				}
				}
						
				#joomla sef url's
				if (!-e $request_filename) {
					rewrite  ^(.*)$  /index.php?q=$1  last;
					break;
								}
					}
						
				if ( $args ~ "mosConfig_{1,21}(=|\%3d)" ) {
				set $args "";
				rewrite ^.*$ http://$host/index.php last;
				return 403;
				}

				if ( $args ~ "base64_encode.*\(.*\)" ) {
				set $args "";
				rewrite ^.*$ http://$host/index.php last;
				return 403;
				}

				if ( $args ~ "(\<|%3C).*script.*(\>|%3E)" ) {
				set $args "";
				rewrite ^.*$ http://$host/index.php last;
				return 403;
				}
			
				if ( $args ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ) {
				set $args "";
				rewrite ^.*$ http://$host/index.php last;
				return 403;
				}

				if ( $args ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ) {
				set $args "";
				rewrite ^.*$ http://$host/index.php last;
				return 403;
				}
			
			
            # 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;
            include /usr/local/nginx/conf/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /home/xxx/public_html/$fastcgi_script_name;
                        }
       }

	   
server {
           
			## Only allow GET and HEAD request methods
			if ($request_method !~ ^(GET|HEAD)$ ) {
			return 444;
			}
			## Deny illegal Host headers
			if ($host !~* ^(xxx.com|www.xxx.com)$ ) {
			return 444;
			}
			## Deny certain User-Agents (case insensitive)
			## The ~* makes it case insensitive as opposed to just a ~
			if ($http_user_agent ~* (Baiduspider) ) {
			return 444;
			}

			## Deny certain Referers (case insensitive)
			## The ~* makes it case insensitive as opposed to just a ~
			if ($http_referer ~* (babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo) ) {
			return 444;
			}
	  
			## Serve an empty 1x1 gif _OR_ an error 204 for favicon.ico
			location = /favicon.ico {
			#empty_gif;
			return 204;
			}


			## All other errors get the generic error page
			error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
                 500 501 502 503 504 505 /error_page.html;
			location  /error_page.html {
			internal;
		  
		 }
		  
	}


Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5464,5465#msg-5465






More information about the nginx mailing list