Home/Article
Esadax JournalFAQ

Enabling SSL and Redirecting HTTP to HTTPS on WordPress with Nginx

To set up a redirection from HTTP to HTTPS on your WordPress site using Nginx, follow these organized steps: 1. Access Nginx Configuration File: Open the Nginx configuration file for your site,

To set up a redirection from HTTP to HTTPS on your WordPress site using Nginx, follow these organized steps:

  1. Access Nginx Configuration File: Open the Nginx configuration file for your site, typically located at /etc/nginx/sites-enabled/000-default.conf.
  2. Modify Server Block Listen Directive:
    • Locate the server block that defines your site.
    • Change listen 80 to listen 443 ssl; to ensure Nginx listens on HTTPS port.
  3. Add Redirect for HTTP Requests:
    • This redirects any request to HTTPS while preserving the domain and path.
  4. Handle Multiple Domains: If you have multiple domains pointing to your site, ensure each server block includes this redirect or use a wildcard approach if applicable.
  5. Test Configuration:
    • After making changes, test using curl commands or check access logs.
    • Clear Nginx cache if necessary before testing to avoid issues.
  6. Inform Users: Optionally, notify users about the redirection for their awareness.
  7. Address Mixed Content Warnings: Implement measures like setting a Content Security Policy to resolve mixed content warnings after ensuring HTTPS redirects are in place.

Within the same server block, add a location block to handle all incoming requests:

location / {
    redirect "https://$host$request_uri";
}
Subscribe