DEV Community

Dendi Handian
Dendi Handian

Posted on • Updated on

HTTPS Local Development using Caddy in Laradock

Having only http protocol on your local development is enough, but sometimes when your project has to access some service locally, your project has to possess the https protocol.

If we are using nginx like in the previous posts, we have to configure the certificate to make it 'https'. So to enable this https in a fake way in our local development, we could use caddy instead of nginx.


If you haven't use Laradock before, try to set up a simple Laravel project like I did here. Then starting from here, we can use caddy as an alternative for nginx.

Configure the Caddy file

You can find the caddy server configuration in caddy\caddy\Caddyfile file. There are some pre-written examples here, but we will use the actual one for the my-awesome-laravel-app from the previous post like this:

https://my-awesome-laravel-app.test {
    root /var/www/my-awesome-laravel-app/public
    fastcgi / php-fpm:9000 php {
        index index.php

    rewrite {
        to {path} {path}/ /index.php?{query}
    log /var/log/caddy/access.log
    errors /var/log/caddy/error.log

    tls self_signed
Enter fullscreen mode Exit fullscreen mode

Run the containers

If you have nginx container running, you have to stop it first with:

docker-compose stop nginx
Enter fullscreen mode Exit fullscreen mode

Then, you should able to run caddy and php-fpm container with this command:

docker-compose up -d caddy php-fpm
Enter fullscreen mode Exit fullscreen mode

You may want to set the APP_URL in the laravel .env:

Enter fullscreen mode Exit fullscreen mode

Then you should able to access it on https://my-awesome-laravel-app.test. Although you will get the Not Secure status next to the address bar like in Chrome browser, you still able to open it in https.

Have fun exploring caddy!

Top comments (0)