HTTPS for WordPress using Caddy

Caddy equivalent code for specific sections of the WordPress support article HTTPS for WordPress.

Best Practices for HTTPS for WordPress #

The Caddy web server activates HTTPS by default for qualifying domain names and automatically enables HTTP → HTTPS redirects. By default, it obtains certificates from Let’s Encrypt and renews them automatically.

example.com { 
    # Set this path to your site's directory:
    root * /var/www/html

    # Enable Gzip compression:
    encode gzip

    # Serve WordPress PHP files through php-fpm:
    php_fastcgi unix//run/php/php7.4-fpm.sock

    # Enable the static file server:
    file_server
}

:writing_hand: Depending on your PHP-FPM config, the php_fastcgi can also be php_fastcgi 127.0.0.1:9000.

Credits and References

Credits

@francislavoie for his contributions within the development reference.

References

  1. HTTPS for WordPress
  2. Development: HTTPS for WordPress using Caddy