Caddy
=====

When Fujin deploys your application, it installs and configures Caddy as a reverse proxy. You may want to use this same Caddy instance for other applications not managed by Fujin.

Using Caddy with Custom Applications
-----------------------------------

Fujin configures Caddy through its API rather than the Caddyfile. If you edit the Caddyfile directly and reload, you'll overwrite Fujin's configuration.

The solution is to use a script that preserves Fujin configurations while adding your own. We've created a Python script that:

1. Gets the current Caddy configuration via the API
2. Preserves all Fujin-managed routes
3. Converts your Caddyfile to JSON
4. Merges your routes with Fujin's routes
5. Applies the combined configuration back to Caddy

You can download the script here: `apply-caddy-config.py </_static/scripts/apply-caddy-config.py>`_

Run it with this one-liner:

.. code-block:: bash

    curl -L -s https://fujin.falcoproject.com/caddy-script | python3 - /path/to/your/Caddyfile

Example Caddyfile:

.. code-block:: text

    myapp.example.com {
        root * /var/www/myapp
        file_server
    }

This script preserves Fujin configurations while adding your custom routes.