Sunday, April 04, 2021

relayd to match http request according to path and change headers

Good day.

I have a setup in OpenBSD 6.8, relayd / httpd and wish to see if I can
have specific http options or headers depending on paths in the requests.

Can I do "match path ..." and set headers ? Until now, all doc I read
say you can set headers globally but not on specific paths.

I can set tags, but trying to match on them and set headers after
triggers syntax error.

Here is an extract of the relayd.conf, where I wish to match on the
static path. I got syntax error when I test this conf (currently
commented) :

http protocol https {
# Various TCP options
tcp { nodelay, sack, socket buffer 65536, backlog 128 }

...

#match path "/static/*" {
#response header set "Access-Control-Allow-Methods" value
"GET,OPTIONS"
#response header set "Access-Control-Allow-Headers" value
"Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-
Modified-Since,Cache-Control,Content-Type"
# }

pass request path "/static/*" forward to <webhosts>
pass request path "/tracker/socket" forward to <apihosts>
pass request path "/socket.io" forward to <apihosts>
pass request path "/*" forward to <apihosts>
}

Thanks for answers.

No comments:

Post a Comment