DO NOT DELETE THIS TEMPLATE. THAT WILL MAKE US SAD
If you are not asking for help, you do not need to use this template
I am a bit torn because I am asking for help but this is a general question. let me know if I should dump the whole thing.
I use several layers of import
to simplify my Caddyfile
. An example is below (it does not look simple at all but various hosts use bits and pieces of the import
, the majority just imports lan
as in the example below)
(netMatchers) {
@internet {
not remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16 127.0.0.0/8
}
@local {
remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16 127.0.0.0/8
}
}
(lanCore) {
log {
level ERROR
format single_field common_log
}
@internet {
not remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16
}
@local {
remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16
}
respond @internet 200
}
(lan) {
import lanCore
reverse_proxy @local {args.0}
}
https://registry-ui.MY-DOMAIN {
import lan registry-ui:80
}
It works great.
I now wanted to add one single element to https://registry-ui.MY-DOMAIN
: an extra header for CORS. I tried
https://registry-ui.MY-DOMAIN {
import lan registry-ui:80
header Access-Control-Allow-Origin '*'
}
but the header is not added (below is the last part of curl -v https://registry-ui.MY-DOMAIN
):
> GET /v2/ HTTP/2
> Host: registry.MY-DOMAIN
> User-Agent: curl/7.58.0
> Accept: */*
>
(... TLS ...)
< HTTP/2 200
< access-control-allow-methods: HEAD
< access-control-allow-methods: GET
< access-control-allow-methods: OPTIONS
< access-control-allow-methods: DELETE
< access-control-expose-headers: Docker-Content-Digest
< content-type: application/json; charset=utf-8
< date: Thu, 12 Aug 2021 13:37:21 GMT
< docker-distribution-api-version: registry/2.0
< server: Caddy
< x-content-type-options: nosniff
< content-length: 2
<
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection #0 to host registry.MY-DOMAIN left intact
{}⏎
Access-Control-Allow-Origin
is not here, so I was wondering: can I mix import
with other configuration entries? (I prefer to ask before I butcher my configuration)