Utkarsh, thanks for the article and a huge help for this noob.
Thomas Bridgeman
1

Hi Thomas,

Thanks for reading article. For redirecting http to https, you need to create two server blocks like below.

server {
listen 80 default_server;
listen [::]:80 default_server;
    server_name domain.example.com;
    return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include your_ssl_certificate;
    location / {
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://private_ip:port;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

Hope this solves your problem.

Like what you read? Give Utkarsh Verma a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.