Nginx

Install

curl https://nginx.org/keys/nginx_signing.key | apt-key add -
echo "deb http://nginx.org/packages/ubuntu/ focal nginx" > /etc/apt/sources.list.d/nginx-stable.list
apt update 
apt install nginx

dhparams

openssl dhparam -out /etc/nginx/dhparam.pem 4096

Simple vhost

server {
   listen 80;
   server_name domain.nl www.domain.nl;
   root /home/DOMAIN/www;
   index index.html;
}

Basic auth

Location / {
    auth_basic "Login for <BLABLA>";
    auth_basic_user_file /home/BLABLA.htpasswd
}

Limit by IP

Location / {
    satisfy any;
    allow 1.2.3.4;
    deny all;
}

FastCGI

location ~ \.(hh|php)$ {
   root /home/USERNAME/www;
   include /etc/nginx/fastcgi_params;
   fastcgi_pass 127.0.0.1:9000;
   try_files $uri=404;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME /home/USERNAME/www$fastcgi_script_name;
   fastcgi_param PATH_TRANSLATED /home/USERNAME/www$fastcgi_script_name;
}

Redirects

server {
   listen       80;
   server_name  olddomain.nl www.olddomain.nl;
   return       301 http://www.DOMAINNAME.nl$request_uri;
}

Or:

if ($scheme = 'http') {
     rewrite ^ https://$host$request_uri? permanent;
}

Regex example:

# Server-wide redirect
rewrite ^/example/something/?.* http://DOMAIN.nl/example permanent;
# Location-specific redirect
location /example/something/ {
  rewrite /example/something/(.*)$ http://DOMAIN.nl/$1;
}

If your way out of a rewrite:

location ~ ^/feed$ { if ($arg_post_type = "") { rewrite ^/rss2/?$http://feedpress.me/example redirect; } }