/ nginx

How To Redirect all HTTP requests to HTTPS with Nginx

Redirect all HTTP traffic to HTTPS in your Nginx config:
server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name example.com www.example.com;
	return 301 https://$server_name$request_uri;
}
If use IP address
server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name _;
	return 301 https://$host$request_uri;
}