Update caddy

main
Kar 2025-05-14 08:00:04 +00:00
parent 6763ebb32b
commit e292f91d81
1 changed files with 47 additions and 1 deletions

48
caddy
View File

@ -1,8 +1,54 @@
nano /etc/caddy/Caddyfile nano /etc/caddy/Caddyfile
minio-api.3027622.siliconpin.com { domain2.com {
reverse_proxy 0.0.0.0: reverse_proxy 0.0.0.0:
} }
yourdomain.com {
@allowed_origins {
origin_regexp ^(https?://(app\.example\.com|localhost:3000|dev\.site\.org))$
}
header @allowed_origins Access-Control-Allow-Origin "{http.request.header.origin}"
header @allowed_origins Access-Control-Allow-Methods "GET, POST, OPTIONS"
header @allowed_origins Access-Control-Allow-Credentials "true"
reverse_proxy localhost:8055
}
yourdomain.com {
# Handle OPTIONS preflight requests
@preflight method OPTIONS
# Allow both HTTP and HTTPS origins (including localhost)
@allowed_origins {
origin http://localhost:3000
origin https://localhost:3000
origin https://*.example.com
origin https://your-production-domain.com
}
# CORS headers for actual requests
header @allowed_origins Access-Control-Allow-Origin "{http.request.header.origin}"
header @allowed_origins Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
header @allowed_origins Access-Control-Allow-Headers "*"
header @allowed_origins Access-Control-Allow-Credentials "true"
header @allowed_origins Vary Origin
# Special handling for preflight requests
header @preflight Access-Control-Allow-Origin "{http.request.header.origin}"
header @preflight Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
header @preflight Access-Control-Allow-Headers "*"
header @preflight Access-Control-Max-Age "3600"
# Proxy to your backend
reverse_proxy localhost:8055 {
header_up Host {host}
header_up X-Real-IP {remote}
header_up X-Forwarded-Proto {scheme}
}
# Ensure OPTIONS requests get 204 responses
respond @preflight 204
}
# The Caddyfile is an easy way to configure your Caddy web server. # The Caddyfile is an easy way to configure your Caddy web server.
# #