nginx
Engine X
location modifier pattern {
…
}
Modifiers:
- (none) — prefix match
=
— exact match~
— case-sensitive regex~*
— case-insensitive regex^~
— non-regex
client_max_body_size 25M;
add_header x-header "value";
Logging
log_format minimal '[$time_local] $status "$request" $body_bytes_sent bytes'
access_log path minimal;
error_log path severity;
Default severity: error
Port 80 traffic → Port 443
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
Clean URLs
try_files $uri $uri.html $uri/index.html =404;
rewrite ^/index(?:\.html|/)?$ / permanent;
rewrite ^/(.*)/index(?:\.html|/)?$ /$1 permanent;
rewrite ^/(.*)(?:\.html|/)$ /$1 permanent;
—URLs Without Trailing Slash or Extension
SSI
Server-side includes
ssi on;
Commands
Subdirectory → subdomain mapping
server_name ~^(?<sub>.+)\.mirrors\.example\.com$;
root /var/www/mirrors/$sub;