Create two server
environments, one for port 80 (http
) and one for port 443 (https
). Have the http
environment do nothing but redirect to the other one:
server {
listen 80;
listen [::]:80;
server_name yesterdayscoffee.de www.yesterdayscoffee.de;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
... all the rest of your configuration
}