1. Output of caddy version
:
v2.6.2
2. How I run Caddy:
I run Caddy on a VPS at Digital Ocean, did not install it using docker, for my domain panamasoberano.com
a. System environment:
Ubuntu 22.04 LTS
b. Command:
sudo systemctl start caddy.service
c. Service/unit/compose file:
Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->
d. My complete Caddy config:
(cors) {
@cors_preflight method OPTIONS
@cors header Origin {args.0}
handle @cors_preflight {
header Access-Control-Allow-Origin "{args.0}"
header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
header Access-Control-Allow-Headers "Content-Type"
header Access-Control-Max-Age "3600"
respond "" 204
}
handle @cors {
header Access-Control-Allow-Origin "{args.0}"
header Access-Control-Expose-Headers "Link"
}
}
panamasoberano.com {
# Set this path to your site's directory.
root * /var/www/
# root * /usr/share/caddy
# Enable the static file server.
file_server
import cors https://panamasoberano.com
# import cors https://panamasoberano.com/.well-known/nostr.json
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
3. The problem I’m having:
I just want to use CORS with my webserver and replicate what it is done on nginx just by adding add_header Access-Control-Allow-Origin *; to configuration, the file on my server that needs to use CORS is located here: https://panamasoberano.com/www/.well-known/nostr.json
So I google how to enable CORS on Caddy but so far everything I tried didn’t worked. if anyone can help I will appreciate it, thanks.
4. Error messages and/or full log output:
Paste logs/commands/output here.
USE THE PREVIEW PANE TO MAKE SURE IT LOOKS NICELY FORMATTED.