Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default response code #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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