1. My Caddy version (caddy version
):
2.0 beta 20
2. How I run Caddy:
/var/www/caddy/caddy run --config /var/www/caddy/Caddyfile --resume --environ
a. System environment:
Ubuntu, systemd
d. My complete Caddyfile or JSON config:
# PTO API
api.pto.stage.example.com {
tls email@example.com
encode gzip
reverse_proxy http://172.31.33.111:9003
header {
Access-Control-Allow-Credentials true
Access-Control-Allow-Headers Cache-Control,Content-Type
Access-Control-Allow-Origin {http.request.header.Referer}
}
}
3. The problem I’m having:
In the above config I’m attempting to set the Access-Control-Allow-Origin to be variable based on the user’s origin. I have 3 sites that need access to the API, however to have credentials allowed you cannot use * it needs to specify the domain.
With caddy 1, you were able to specify a list with the cors plugin, I’m trying to figure out how to replicate a similar functionality
4. Error messages and/or full log output:
N/A
5. What I already tried:
I’ve checked out the variables here JSON Config Structure - Caddy Documentation and have tried using the http.request.header.Referer
value, however that will be the complete URL and I need just the host portion.
If a new variable needs to be added for this I would suggest http.request.origin