nginx

Redirect all http traffic to https

Add following to the server block of the nginx configuration.

1
return 301 https://$server_name$request_uri;

In case you want only a few endpoints to redirect to https, rather than all the traffic, you need to create two server blocks. One for http and other for https.

location block under each determines which endpoint redirects to https.

See this SO answer