load_module /usr/lib/nginx/modules/ngx_http_geoip2_module.so; worker_processes 1; events { worker_connections 1024; } http { sendfile on; #client_max_body_size 1500M; client_max_body_size 15000M; server_names_hash_bucket_size 1024; proxy_http_version 1.1; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header Accept-Encoding ""; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; #compression settings gzip on; gzip_types text/plain application/xml application/json image/svg+xml text/css; gzip_min_length 1000; #custom log format to display the webiste visited and the IP used log_format my_custom_format '$http_host \t $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'; log_format ip_audit '$remote_addr [$time_local]'; log_format backend_debug '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' 'upstream_status=$upstream_status'; log_format localization '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '$geoip2_data_city_name $geoip2_data_country_name'; log_format blocked_fmt '$http_host \t $remote_addr - [$time_local] ' 'Blocked Country: $geoip2_data_country_iso_code ' '"$request" $status'; log_format deny_style 'deny $remote_addr; #$geoip2_data_city_name $geoip2_data_country_name'; server { listen 80; listen 443 default ssl; ssl_certificate /etc/nginx/ssl/live/geeraert.eu/fullchain.pem; # managed by$ ssl_certificate_key /etc/nginx/ssl/live/geeraert.eu/privkey.pem; # managed $ location / { proxy_pass http://1.1.1.1; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } } # Connection header for WebSocket reverse proxy map $http_upgrade $connection_upgrade { default upgrade; '' close; } geoip2 /data/dbip-country-lite-2026-01.mmdb{ $geoip2_data_country_iso_code country iso_code; $geoip2_data_city_name city names en; $geoip2_data_country_name country names en; } map $geoip2_data_country_iso_code $allowed_country { default no; FR yes; # Allow France GB yes; # Allow UK #NL yes; # Allow netherland #IN yes; # Allow India } # Full list of country codes: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes map $allowed_country $should_log_blocked { no 1; default 0; } include /etc/nginx/deny.d/*.conf; include /etc/nginx/conf.d/*.conf; include /etc/nginx/blacklisted.d/*.conf; include /etc/nginx/geoip.d/*.conf; # adding this line for the fial2ban settings #map $cookie_session_id $blck_lst_ses { include /etc/nginx/blacklisted.d/blacklisted-sessions.map; } #add extra file for any extra work include /etc/nginx/extra.conf.d/*.conf; resolver 127.0.0.1 ipv6=off valid=40s; # The DNS IP server #https://www.tweaked.io/guide/nginx-proxying/ proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:60m max_size=1G; }