Hello! On Mon, Jul 18, 2022 at 04:02:53PM +0100, Chris Newton via nginx-devel wrote:
> I'm adding a variable that wants to provide an absolute URL to proxy_pass, > whose value is based in part on a database lookup - but if the search key > is not found in that database, my handler function is returning an > NGX_ERROR which seemed reasonable (there is no good default I can return), > so just causing a 500 error at that point is not unreasonable. > > However, that also causes an error to be logged by ngx_http_proxy_eval() > for every request, which i'd like to avoid. NGX_ERROR means a fatal error and it is expected to be logged - by the code where the error appears. Right now scripting infrastructure silently converts errors from variable handlers to empty values - but this is something to change, since this isn't a safe approach and can cause various issues. Consider returning a value instead - something like an empty value or a value with the not_found flag. The logging you see is, however, unrelated. It's ngx_http_proxy_eval() which complains about an invalid URL after variable evaluation. That's because proxy_pass is expected to be reasonably configured to always result in a valid URL. If it doesn't, this is considered to be a configuration error and reported, both to the user with 500 (Internal Server Error) and to the error log. If in your case a valid URL for proxying is not always available, consider re-configuring nginx to avoid the error condition. In particular, providing a dummy URL which immediately returns an error or an explicit check before proxying might be considered. -- Maxim Dounin http://mdounin.ru/ _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org