Skip to content

Add example vhost for caddy webserver #733

@alexander-schranz

Description

@alexander-schranz

The caddy webserver is more and more common. Even deployer is using it in its new deployment feature where it actually will install caddy webserver and php on a blank ubuntu server when activated in deployment.

So it would be really nice to have caddy vhost which works the same as nginx: https://docs.sulu.io/en/latest/cookbook/web-server/nginx.html

Important mechanisms of the VHost

Check for static files fallback to index.php

Sulu generates thumbnails the first time they are requested, so a fallback mechanism is required. In nginx this is achieved via:

    location / {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
    }

Static files cachelifetime

Static files will have a specified cachelifetime in nginx:

   location ~* \.(?:ico|css|js|gif|webp|jpe?g|png|svg|woff|woff2|eot|ttf|mp4)$ {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
        access_log off;
        expires 1y;
        add_header Pragma public;
        add_header Cache-Control "public, immutable";
    }

This will mostly be the biggest difference to Symfony caddy configuration. Currently there is not yet any official symfony caddy vhost: symfony/symfony-docs#17471

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions