Skip to content

Instantly share code, notes, and snippets.

@KavenTheriault
Last active November 16, 2017 23:47
Show Gist options
  • Save KavenTheriault/0641f8952ec8df0aaf52428d955d253c to your computer and use it in GitHub Desktop.
Save KavenTheriault/0641f8952ec8df0aaf52428d955d253c to your computer and use it in GitHub Desktop.
Nginx - Redirect http to https

Create file the following file /etc/nginx/site-available/redirect_http_to_https

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

Create symbolic link in the /etc/nginx/site-enabled/ folder

sudo ln -s /etc/nginx/sites-available/redirect_http_to_https /etc/nginx/sites-enabled/

Restart Nginx

sudo systemctl restart nginx.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment