Laravel Caddyfile Example

Migrating all my Laravel projects. Any body can help with file example?

on nginx it’s look like:

server {
    listen 80;

    server_name example.com;
    root /srv/public;
    index index.php index.html index.htm;

    access_log /var/log/nginx/osr-access.log;


    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php {
            try_files $uri /index.php =404;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_buffers 8 16k;
            fastcgi_buffer_size 32k;
            proxy_send_timeout 180s;
            proxy_read_timeout 180s;
            include fastcgi_params;
        }

    location ~ /\.ht {
        deny all;
    }
}

Best regards to CaddyServer. And sorry for bad english.

UPD
In principle, the file came from the example for wordpress, but perhaps there is a way right?

This should get you started.

example.com {

    root ./public
    log ./storage/logs/caddy-access.log
    errors ./storage/logs/caddy-error.log

    fastcgi / 127.0.0.1:9000 php {
        index index.php
    }
    
    rewrite {
        r .*
        ext /
        to /index.php?{query}
    }

}
3 Likes

Wow! Nice! Great! Awesome its working!

Would you like to add this to the GitHub - caddyserver/examples: OBSOLETE. This repo was for Caddy v1. For v2 and newer, see our forum's wiki category. repository? :slight_smile: Try to strip it down as simple as it can be, and I think people will appreciate that.

2 Likes

maked pull request

1 Like

Actually the three lines in rewrite can be shorten to one.

example.com {

    root ./public
    log ./storage/logs/caddy-access.log
    errors ./storage/logs/caddy-error.log

    fastcgi / 127.0.0.1:9000 php {
        index index.php
    }
    
    rewrite {
        to {path} {path}/ /index.php?{query}
    }

}
2 Likes

Thanks @abiosoft :slight_smile:

I cannot understate how great Caddy is! You rock mholt! I recently got a new job where I am learning PHP. Caddy + PHP is dead simple. I would way rather be using Golang but Caddy makes PHP a bit less of a sacrifice.

1 Like

Thank you Seth :slight_smile: Glad you find it useful.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.