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 option to ignore allow_list for a certain route #17

Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -21,6 +21,7 @@ If you only want to install Caddy, you don't need to set any variables. If you w
Afterwards, you can define a list of `routes` composing of the following values:

* `path`: Path that should be matched. Let it empty for everything or e.g. `/api/*` for something specific.
* `public`: If `true` the site's `allowlist` will not be applied to this route, thus making this route publicly available. Defaults to `false`.
* `reverse_proxy_destination`: Where the requested should be proxied.
* `strip_prefix`: If set, the matched `path` will be removed from the request to the destination system. This means, if somebody requests the route `/api/v1/hello` at the reverse proxy and you set `/api/*` as path, the request will be sent as `/v1/hello` to the destination system.

Expand Down
6 changes: 3 additions & 3 deletions templates/Caddyfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
{%- for route in site.routes %}
{% if route.strip_prefix is defined and route.strip_prefix %}
handle_path {{ route.path }} {
{% else %}
{%- else %}
handle {{ route.path }} {
{%- endif %}
{%- if site.allowlist is defined %}
{%- if site.allowlist is defined and not (route.public | default(false)) %}
reverse_proxy @allowlist {{ route.reverse_proxy_destination }}
respond @not_allowlist 404
{%- else %}
Expand All @@ -42,7 +42,7 @@

{% if site.certificate_file is defined %}
tls {{ site.certificate_file }} {{ site.certificate_key }}
{% endif -%}
{%- endif %}
}

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