HowTo: Nginx Redirect HTTP To HTTPS with Rewrite 301 Rules
To redirect HTTP traffic to HTTPS in Nginx, you can add the following rewrite rule in the server block of your Nginx configuration file: server { listen 80; server_name example.com; return 301 https://$host$request_uri; } Replace example.com with your domain name. This rule will listen for incoming HTTP traffic on port 80, and for all requests, … Read more