server { listen 443; server_name #serverNameVar; ssl on; ssl_certificate /etc/letsencrypt/live/#serverNameVar/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/#serverNameVar/privkey.pem; location / { proxy_pass #http://127.0.0.1:8080/; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; } } server { listen 80; server_name #serverNameVar; location / { return 301 https://#serverNameVar$request_uri; } }