How about this: server { listen 80; server_name *.mydomain.com; return 301 https://$http_host$request_uri; } Andrejs Posted at Nginx Forum: http://forum.nginx.org/read.php?2,261751,261762#msg-261762