1. The problem I’m having:
Hi, I am using caddy discord to do an auth to a web service, but as the cookie keeps being passed after using the plugin, so when i request a file, image or audio i keep hitting cf-cache-status: MISS
while using cURL for debugging i get cf-cache-status: HIT
I’d like to remove the cookies on file_server, but i can’t find a way to do so.
2. Error messages and/or full log output:
__Wrong (via caddy)__
HTTP/2 200
date: Sat, 28 Sep 2024 02:21:12 GMT
content-type: audio/mpeg
content-length: 181053
cache-control: public, max-age=31536000, must-revalidate
etag: "d32h57uhglfdxxx9"
last-modified: Tue, 30 Jul 2024 01:15:12 GMT
permissions-policy: interest-cohort=()
preload:
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: DENY
x-xss-protection: 1; mode=block
____cf-cache-status: MISS____
accept-ranges: bytes
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=XT2ufKWmKbxX1PGj75QnyIo%2Fbxxxxxxx39HLwl95G2dM%2FkWHMhDoIC%2Ff8uR2uVOn%2FA%2FBQ5rJxU2lnSao%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 8ca0423xxx1e9c-EZE
GET /songs/1420/preview.mp3 HTTP/2
Host: baubau.lena.moe
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
Referer: https://baubau.lena.moe/
DNT: 1
Sec-GPC: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Connection: keep-alive
Cookie: _DISCORDCADDY_guild_checker_b16125370b6fadc8....
__Good__ via cURL
curl -I https://baubau.lena.moe/songs/1591/main.ogg
HTTP/2 200
date: Sat, 28 Sep 2024 02:11:42 GMT
content-type: audio/ogg
content-length: 2543784
cache-control: public, max-age=31536000, must-revalidate
etag: "cwaebqys7u2o1iiso"
last-modified: Tue, 17 Oct 2023 03:32:12 GMT
permissions-policy: interest-cohort=()
preload:
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: DENY
x-xss-protection: 1; mode=block
____cf-cache-status: HIT_____
age: 4
accept-ranges: bytes
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=vfg%2BhznqFebRSeIOX6xxxxxG2PPiIvSmygpXY6WHrho7iT8tdFSk%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 8ca034517d23xxxx-EZE
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
4. How I installed and ran Caddy:
a. System environment:
b. Command:
@cachedFiles {
path *.mp3 *.ogg *.jpg *.png
}
# Set cache headers for specific file types
header @cachedFiles {
Cache-Control "public, max-age=666666, must-revalidate"
}
# Modify request headers, removing the _DISCORDCADDY_guild_checker cookie
header {
# Match and remove the dynamic _DISCORDCADDY_guild_checker_ cookie from request headers
-Cookie "(?i)(^_DISCORDCADDY_guild_checker_[^;]+;? ?|;? ?_DISCORDCADDY_guild_checker_[^;]+)"
-Cookie _DISCORDCADDY_guild_checker_
}
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
c. Service/unit/compose file:
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
d. My complete Caddy config:
https://baubau.lena.moe:443, https://www.baubau.lena.moe:443 {
import header-gen
handle_errors {
rewrite * /{err.status_code}
reverse_proxy https://http.cat {
header_up Host {upstream_hostport}
replace_status {err.status_code}
}
}
handle /sw.js {
rewrite * /mnt/hdd/data/serv-web/public/sw/sw.js
php_fastcgi unix//run/php/php8.1-fpm.sock
file_server
}
@static path_regexp ^/(assets|songs|src|img|audio|fonts|song_skins|live2d_api|api/config)/
handle @static {
root * /mnt/hdd/data/serv-web/public/
@songpreview path_regexp songs ^/songs/([0-9]+)/preview\.mp3$
handle @songpreview {
try_files {path} /api/preview?id={re.songs.1}
}
@songpreview2 path_regexp songs ^/songs/([0-9]+)/preview\.ogg$
handle @songpreview2 {
try_files {path} /api/preview?id={re.songs.1}
}
file_server
}
@cachedFiles {
path *.mp3 *.ogg *.jpg *.png
}
# Set cache headers for specific file types
header @cachedFiles {
Cache-Control "public, max-age=666666, must-revalidate"
}
# Modify request headers, removing the _DISCORDCADDY_guild_checker cookie
header {
# Match and remove the dynamic _DISCORDCADDY_guild_checker_ cookie from request headers
-Cookie "(?i)(^_DISCORDCADDY_guild_checker_[^;]+;? ?|;? ?_DISCORDCADDY_guild_checker_[^;]+)"
-Cookie _DISCORDCADDY_guild_checker_
}
handle /favicon.ico {
root * /mnt/hdd/data/serv-web/public
file_server
}
@wasm {
path *.wasm
}
header @wasm Content-Type application/wasm
route /discordauth/callback {
discord callback
}
route /* {
# Player endpoint
protect using guild_checker
reverse_proxy 127.0.0.1:34801
}
route /api/preview {
reverse_proxy 127.0.0.1:34801
}
route /p2* {
# Multiplayer endpoint
protect using guild_checker
reverse_proxy 127.0.0.1:34802
}
respond "Welcome to nothing"
}
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.