My recommendation would be:
- Change your current
serverblock to be the block for SSL. - Make a new
serverblock that redirects all HTTP requests to HTTPs.
For reference, here is such a redirect block:
server {
listen 80;
server_name domain.com;
return 301 https://$host$request_uri;
}
Here’s how the SSL configuration could look like:
server {
listen 443 ssl;
server_name domain.com;
ssl_certificate /etc/ssl/certs/cert.crt;
ssl_trusted_certificate /etc/ssl/certs/cert.crt;
ssl_certificate_key /etc/ssl/private/cert.key;
ssl_ciphers "AES256+EECDH";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
add_header Strict-Transport-Security "max-age=63072000;";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
ssl_stapling on;
ssl_stapling_verify on;
client_max_body_size 20m;
location / {
proxy_pass http://unix:/var/discourse/shared/vorkurs/nginx.http.sock:;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# proxy_redirect http://vorkurs-discourse.cs.uni-saarland.de/ https://vorkurs-discourse.cs.uni-saarland.de/;
}
}
Watch out: My example enables HSTS. If your site goes live with this configuration, visitors that have seen it will refuse to use http for up to 2 years.