Disable access by IP and unknown hosts

Hi.

How can I disable access by IP to my server and by hosts not defined
in server_name?

I only have www.domain.com on server_name but people can still access
the site via mail.domain.com or by the IP address.

Thanks

Leonardo.

On Tue, May 11, 2010 at 04:44:33PM +1000, Leonardo C. wrote:

Hi.

How can I disable access by IP to my server and by hosts not defined
in server_name?

I only have www.domain.com on server_name but people can still access
the site via mail.domain.com or by the IP address.

http://nginx.org/en/docs/http/request_processing.html#how_to_prevent_undefined_server_names


Igor S.
http://sysoev.ru/en/

Cheers!

"Note that you should set a name for this server, otherwise nginx will
use the hostname. "

How do I “set a name” for a server in nginx?

Thanks

Cheers Igor!

On Tue, May 11, 2010 at 05:02:42PM +1000, Leonardo C. wrote:

Cheers!

"Note that you should set a name for this server, otherwise nginx will
use the hostname. "

How do I “set a name” for a server in nginx?

http://nginx.org/en/docs/http/server_names.html#miscellaneous_names


nginx mailing list
[email protected]
nginx Info Page


nginx mailing list
[email protected]
nginx Info Page


Igor S.
http://sysoev.ru/en/

Hallo… before i create new thread i want to ask…
i was try with Igor S. tutorials… but didn`t work.

i want to disable access from browser,
ex = http://127.0.0.1/

i have to IP address for my server… how to disable ALL IP access from
browser.?

Posted at Nginx Forum:

On 29 October 2011 21:06, MyName [email protected] wrote:

i want to disable access from browser,
ex = http://127.0.0.1/

To disable access by IP address, try setting your default server,
usually in nginx.conf, as follows:

# Default server
server {
    listen 80;
    listen 443;

return 403;
}

Hallo Nginx U…

i was try with your config, its work, but when i open with my domain is
riderect to 403 page… i cant access my domain,
this is for config server

user nginx;
worker_processes 10;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local]

“$request” ’
'$status $body_bytes_sent “$http_referer” ’
‘“$http_user_agent” “$http_x_forwarded_for”’;

access_log  /var/log/nginx/access.log  main;

sendfile       on;
tcp_nopush     on;
tcp_nodelay    on;

keepalive_timeout  65;

}

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;
}

Posted at Nginx Forum:

On 30 October 2011 19:57, MyName [email protected] wrote:

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

}
}