Example: YOURLS

If you want to use the URL shortener service YOURLS, you have to use a special configuration in order to make it work with Caddy 2.

Here’s the minimum Caddyfile configuration you will need :

domain.com {
    root * /var/www/yourls
    route {
        try_files {path} {path}/index.php yourls-loader.php
        php_fastcgi unix//run/php/php-version-fpm.sock
    }
    file_server 
}

Don’t forget to change the configuration :

  • domain.com with your domain name ;
  • /var/www/yourls with the actual path where you installed YOURLS ;
  • unix//run/php/php-version-fpm.sock with the correct php-fpm sock path.
6 Likes

I use somewhat similar Caddyfile too. Here’s mine that is compatible with Caddy version 2.10…

yourls.example.com {
    # update the path to the actual path to yourls installation
    root /home/user/sites/yourls.example.com/public

    # update it with actual socket or port value
    php_fastcgi unix//run/php/fpm.sock

    file_server {
        index index.php index.html index.txt
    }

    try_files {path} {path}/ /yourls-loader.php?{query}

    # rest of the config
}