Disable access by IP and unknown hosts

Nginx User nginx at nginxuser.net
Sun Oct 30 17:22:28 UTC 2011


On 30 October 2011 19:57, MyName <nginx-forum at nginx.us> wrote:
> server {
>    listen       80;
>    listen       443;
>    return      403;
>    server_name  domaingue.crots
>                 www.domaingue.crots
>                 ;
>
>    location / {
>        root   path/to/html;
>        index  index.php index.html index.htm;
>    }


You need a separate server block for your domain. Example below. You
need to change to match your specific needs (E.G. location for php)

 # Default server
   server {
       listen 80;
       listen 443;
       return 403;
   }

 # domaingue.crots server
 server {
 	server_name  domaingue.crots www.domaingue.crots;
 	
 	# Put "root" and "index" directives at the server level
 	root   path/to/html;
 	index  index.php index.html index.htm;
 	
 	# As many locations as needed
 	location / {
 		try_files $uri $uri/ =404;
	}
 	# As many locations as needed
	location ~ .+\.php$ {
		# Linebelow is important for security
		location ~ \..*/.*\.php$ { return 400; }
		
		#proxy_pass/fastcgi_pass etc
	}
}



More information about the nginx mailing list