Skip to content

Category: FreeBSD

How to get the real IP address on Nginx when you use Cloudflare

How to get the real IP address on Nginx when you use Cloudflare. If you want to get the real IP address on Nginx when you use Cloudflare, you can use the ngx_http_realip_module module. You can find here more information regarding this module: http://nginx.org/en/docs/http/ngx_http_realip_module.html On Nginx, http section: http { …… … other options ……

Blocking access by user agent in Nginx

How to block access by user agent in Nginx. In this configuration, i will use ngx_http_map_module. Inside http section: include /etc/nginx/blacklist; Inside server section (virtual host). We will return 444 status code. if ($block_ua) { return 444; } The blacklist file (example) map $http_user_agent $block_ua { default 0; ~*profound 1; ~*scrapyproject 1; ~*netcrawler 1; ~*nmap…