To redirect a browser from http to https, you don't need to do an 'if' or 'rewrite'... The following would be the most efficient (and simplest)... server { listen 80; server_name myapps.example.com; access_log off; return 301 https://$host$request_uri; }