Es geht noch eleganter. Für eine Domain wie frank-mankel.de z.B. so. Muss das mal hier parken, damit ich nicht immer wieder danach suchen muss.
server { server_name www.example.com example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; ssl_certificate /path/to/server.cert; ssl_certificate_key /path/to/server.key; server_name www.example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; ssl_certificate /path/to/server.cert; ssl_certificate_key /path/to/server.key; server_name example.com; <locations for processing requests> }Quelle: https://serverfault.com/questions/258378/remove-www-and-redirect-to-https-with-nginx