server {
listen 80;
listen [::]:80;
server_name _;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
allow x.x.x.x;
allow y.y.y.y;
deny all;
location / {
root /var/www/html;
}
}
server {
listen 80;
listen [::]:80;
server_name ;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
root /files;
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime on;
}
}
- Set real ip in nginx ( through cloudflare )
server {
listen 80;
listen [::]:80;
server_name _;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location = /robots.txt {
alias /etc/nginx/conf.d/robots.txt;
}
# set real ip from cloudflare
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
location / {
root /var/www/html;
}
}