# Rewrite requests for domains to their corresponding www # It is not necessary to configure the redirect for SSL # because we expect the browser to try HTTP if HTTPS fails server { listen 80; server_name ~^(?!www\.)(?.+)$; return 301 https://www.$domain$request_uri; } # Serve general purpose HTML if no server matches # Usually this just shows a message that NGINX has been # configured successfully server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /var/www/html; index index.html index.htm welcome.html welcome.htm; location / { try_files $uri $uri/ =404; } }