Skip to content

Commit

Permalink
Add default response code
Browse files Browse the repository at this point in the history
  • Loading branch information
bardocuteam committed Oct 29, 2024
1 parent 2473656 commit defc2d2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ If you only want to install Caddy, you don't need to set any variables. If you w
* `certificate_file`: You can set this variable if you want to provide the certificate by yourself (Optional). The certificate needs permissions `0640`, with root as Owner and Caddy as Group.
* `certificate_key`: You can set this variable if you want to provide the certificate by yourself (Optional).
* `domain`: The domain caddy should listen to.
* `default_response_code`: The code caddy will respond if the route is not defined. If not set, Caddy default behavior responds with code `200`.

Afterwards, you can define a list of `routes` composing of the following values:

Expand Down
1 change: 1 addition & 0 deletions molecule/reverse-proxy/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
vars:
caddy_sites:
- domain: example.com
default_response_code: 404
routes:
- path: ''
reverse_proxy_destination: 192.168.50.2
Expand Down
2 changes: 1 addition & 1 deletion molecule/reverse-proxy/files/Caddyfile.expected
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ example.com {
respond @not_allowlist 404
}


respond 404
}


Expand Down
4 changes: 4 additions & 0 deletions templates/Caddyfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
{% if site.certificate_file is defined %}
tls {{ site.certificate_file }} {{ site.certificate_key }}
{%- endif %}

{% if site.default_response_code is defined %}
respond {{ site.default_response_code }}
{%- endif %}
}

{% if (site.additional_forwarding_ports is defined) and (site.additional_forwarding_ports | length > 0) %}
Expand Down

0 comments on commit defc2d2

Please sign in to comment.