Skip to content

Instantly share code, notes, and snippets.

@LoveDuckie
Last active July 5, 2021 23:35
Show Gist options
  • Save LoveDuckie/685e55c1e2c5695b011232b894190f8f to your computer and use it in GitHub Desktop.
Save LoveDuckie/685e55c1e2c5695b011232b894190f8f to your computer and use it in GitHub Desktop.
A default server configuration for NGINX. Useful as a "catch-all" configuration when there's no server configuration available for a domain on the host that NGINX is running from. Read more: https://lucshelton.com/blog/configuring-a-default-server-for-nginx/
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name_in_redirect off;
server_name default_server;
server_tokens off;
charset utf-8;
access_log /var/log/nginx/host.access.log main;
error_log /var/log/nginx/host.error.log warn;
# SSL
ssl_certificate /etc/nginx/ssl-default/default-fullchain.pem;
ssl_certificate_key /etc/nginx/ssl-default/default-privkey.pem;
root /var/www/default;
index index.html index.htm;
location ~* ^.+ {
try_files $uri $uri/ =404;
}
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 403 /403.html;
location = /404.html {
root /var/www/default;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/default;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment