Skip to content

Instantly share code, notes, and snippets.

@juanlugm
Created September 6, 2019 23:26
Show Gist options
  • Save juanlugm/441aedaf12c5fb7ac31a23c47821f180 to your computer and use it in GitHub Desktop.
Save juanlugm/441aedaf12c5fb7ac31a23c47821f180 to your computer and use it in GitHub Desktop.
HTTPS - Spring Boot 2 - Nginx
server {
server_name mydomain.com www.mydomain.com;
location / {
root /var/www/mydomain.com/html;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?q=$request_uri;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name mydomain.com www.mydomain.com;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment