Configuration for Caddy Web Server server

  • Last updated on January 20, 2024

  • If you are using a Caddy Web Server that does not support .htaccess rules, additional configuration is required for the Converter for Media plugin to work properly.

  • Step 1.

    Start an SSH connection to your website or forward this instruction to your server administrator.

  • Step 2.

    Go to the host configuration directory using the command:

    cd /etc/caddy

    Use the command to edit the configuration file:

    nano Caddyfile

  • Step 3.

    In the configuration file, find the block responsible for your domain and add the following rules in it:

    # BEGIN Converter for Media
    header /wp-content/*/*.jpg Cache-Control "private"
    header /wp-content/*/*.jpeg Cache-Control "private"
    header /wp-content/*/*.png Cache-Control "private"
    header /wp-content/*/*.webp Cache-Control "private"
     
    @acceptsAvif {
        header Accept *image/avif*
        path_regexp avif ^/wp-content/(.+)/(.+)\.(jpg|jpeg|png|webp)$
    }
    @acceptsWebp {
        header Accept *image/webp*
        path_regexp webp ^/wp-content/(.+)/(.+)\.(jpg|jpeg|png)$
    }
     
    handle @acceptsAvif {
        @hasAvif file /wp-content/uploads-webpc/{re.avif.1}/{re.avif.2}.{re.avif.3}.avif
        rewrite @hasAvif /wp-content/uploads-webpc/{re.avif.1}/{re.avif.2}.{re.avif.3}.avif
    }
    handle @acceptsWebp {
        @hasWebp file /wp-content/uploads-webpc/{re.webp.1}/{re.webp.2}.{re.webp.3}.webp
        rewrite @hasWebp /wp-content/uploads-webpc/{re.webp.1}/{re.webp.2}.{re.webp.3}.webp
    }
    # END Converter for Media

    Please remember to:

    • add rules in the block responsible for your domain
    • if you have several blocks responsible for your domain (e.g. separate for HTTP and HTTPS), add rules in all blocks
    • add these rules before other directives in the block
  • Step 4.

    Restart the Caddy server using the command:

    service caddy restart

  • Step 5.

    That’s all! Our plugin will work properly.

    If you encounter any problems, please, contact us. We will try to help you.

We uses cookies

This website uses cookies to help it function and track how you interact with it. We will only use cookies if you accept our Cookie Policy by clicking Accept Cookies. If you click Decline, we will only use cookies that are necessary for the operation of our website.

One moment more ...

We need your consents so that we can provide services to you. Please read the Privacy Policy and the Terms and Conditions. Click Accept All if you have read and agree to our Privacy Policy and our Terms and Conditions.

Please wait ...

The Checkout session is being generated for you. In case of any problems, please contact us.