Index | Thread | Search

From:
Lloyd <ng2d68@proton.me>
Subject:
Re: relayd: set User-Agent for HTTP healthchecks
To:
Rafael Sadowski <rafael@sizeofvoid.org>
Cc:
tech@openbsd.org, Joel Carnat <joel@carnat.net>, Kirill Bychkov <kirby@linklevel.net>
Date:
Fri, 27 Feb 2026 06:14:08 +0000

Download raw body.

Thread
Personal style preference, but I would define the user-agent in a macro rather than hard-code it in multiple places.

Doesn't relayd spit out error pages with an identifier string? Perhaps it's already defined elsewhere.

Regards
Lloyd

Rafael Sadowski wrote:

> Joel Carnat notice that GoToSocial does not like it when we sent no
> User-Agent and returns an HTTP/418. This simple diff adds User-Agent to
> all HTTP/HTTPS checks.
> 
> As I see it, we use "User Agents" in other places (ftp,acme-client...).
> When I look at all my (aws) load balancers and checks, I get a user
> agent from all of them.
> 
> diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
> index fcdfb8e92e3..44ec18cbcfc 100644
> --- a/usr.sbin/relayd/parse.y
> +++ b/usr.sbin/relayd/parse.y
> @@ -921,7 +921,7 @@ tablecheck	: ICMP			{ table->conf.check = CHECK_ICMP; }
>  				YYERROR;
>  			}
>  			if (asprintf(&table->sendbuf,
> -			    "HEAD %s HTTP/1.%c\r\n%s\r\n",
> +			    "HEAD %s HTTP/1.%c\r\nUser-Agent: relayd\r\n%s\r\n",
>  			    $2, strlen($3) ? '1' : '0', $3) == -1)
>  				fatal("asprintf");
>  			free($2);
> @@ -936,7 +936,7 @@ tablecheck	: ICMP			{ table->conf.check = CHECK_ICMP; }
>  			}
>  			table->conf.check = CHECK_HTTP_DIGEST;
>  			if (asprintf(&table->sendbuf,
> -			    "GET %s HTTP/1.%c\r\n%s\r\n",
> +			    "GET %s HTTP/1.%c\r\nUser-Agent: relayd\r\n%s\r\n",
>  			    $2, strlen($3) ? '1' : '0', $3) == -1)
>  				fatal("asprintf");
>  			free($2);
> diff --git a/usr.sbin/relayd/relayd.conf.5 b/usr.sbin/relayd/relayd.conf.5
> index 5ae11c5ac01..943926a448a 100644
> --- a/usr.sbin/relayd/relayd.conf.5
> +++ b/usr.sbin/relayd/relayd.conf.5
> @@ -279,6 +279,9 @@ If
>  is specified, it is used as the
>  .Dq Host:
>  header to query a specific hostname at the target host.
> +A
> +.Dq User-Agent: relayd
> +header is always included in the request.
>  To validate the HTTP return code, use this shell command:
>  .Bd -literal -offset indent
>  $ echo -n "HEAD <path> HTTP/1.0\er\en\er\en" | \e
> 
>