Configuring Nginx for WordPress

A typical Vhost file (for example /etc/nginx/sites-available/default) would look like this: server {   listen   80;   server_name  YOUR_SERVER_NAME;   access_log  /var/log/nginx/access.log;   root /var/www;   index index.php;   location / {    index index.php;    try_files $uri $uri/ /index.php?q=$uri&$args;   }   location ~ \.php$ {               […]

Blocking Referers and IP adresses using mod_rewrite

Blocking a single referer: RewriteEngine on RewriteCond %{HTTP_REFERER} example\.net [NC] RewriteRule .* – [F] Block more than one referrer: RewriteEngine on RewriteCond %{HTTP_REFERER} example\.net [NC,OR] RewriteCond %{HTTP_REFERER} anotherexample\.net RewriteRule .* – [F] Using rewritemap: RewriteMap blacklist txt:/path/to/blacklist.txt RewriteCond %{HTTP_REFERER} ^(.*)$ RewriteCond ${blacklist:%1} ^denied$ [NC] RewriteRule (.*) – [F] Just create a text file blacklist.txt with the following […]

Mass Virtual Hosting with mod_rewrite RewriteMap and PHP

Here is a simple possibility to control a lot of virtual hosts using a simple PHP script to map them to the right path. First of all you need to make sure that mod_rewrite is loaded: a2enmod rewrite Further we need these packages: php5-cli php5-mysql mysql-server What we're doing now is a simple Url-Rewriting to a […]