Skip to content

Category: Webservers

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…

Mass virtual hosting with apache through mod_rewrite

If you are a developer and you’re working with several subdomains for development purposes, you can create a single virtualhost, without the need to add subdomains and restart/reload the apache web server. Directory structure (example): /var/www /var/www/project1.unixteacher.org /var/www/project2.unixteacher.org /var/www/project3.unixteacher.org /var/www/development.unixteacher.org One single virtualhost for any subdomain: <VirtualHost *> DocumentRoot /var/www ServerName unixteacher.org ServerAlias *.unixteacher.org CustomLog…

HTTP DoS Protection with nginx

HTTP DoS Protection with Nginx through ngx_http_limit_conn_module and ngx_http_limit_req_module modules. The ngx_http_limit_conn_module module is used to limit the number of connections per the defined key, in particular, the number of connections from a single IP address. Not all connections are counted. A connection is counted only if it has a request processed by the server…