[squid-users] Setting header with external auth helper error message

Irem Kuyucu irem.kuyucu at surfsharkteam.com
Tue Dec 6 13:54:35 UTC 2022


Hello,

I'm trying to get Squid (4.9) to reply to the client with a custom
header which contains the error message returned from the external
auth helper binary.

For example, I'd like Squid to reply with a header like this:
X-Custom-Err: ERR NO_BACKEND
or
X-Custom-Err: NO_BACKEND
Where "ERR NO_BACKEND" is a response gathered from the auth helper.

I've tried setting this in squid.conf, this way I can see the header
however its value is always '-':

reply_header_add X-Custom-Err "%err_detail"

I also tried to define a custom error by modifying squid.conf and
error-details.txt. That also didn't work, the value is always set to
'-'.
/etc/squid.conf:

error_directory /etc/squid/error_directory/
deny_info CUSTOM_ERR_ACCESS_DENIED custom-auth
reply_header_add X-Custom-Err "%err_detail"

/etc/squid/error_directory/error-details.txt:

name: CUSTOM_ERR_ACCESS_DENIED
detail: "%m"
descr: "Access denied"

"%m" is the error message returned by external auth helper according
to https://wiki.squid-cache.org/Features/CustomErrors#ERR_.2A_template_codes_for_embedding
I also tried to log "%err_code %err_detail %et %ea" but all of these
values except err_code are logged as '-'.
Does anyone know how to do this or if this is possible to do in the first place?

Thanks in advance,
Irem


More information about the squid-users mailing list