cancel
Showing results for 
Search instead for 
Did you mean: 

NGINX Plus health_check doesn't support $proxy_host

arian
Nimbostratus
Nimbostratus

It seems like NGINX Plus's health_check directive doesn't support variable hosts. (I'm on R24)

We can see here that the default is $proxy_host:

 

proxy_set_header Host       $proxy_host;

 

However, when using health_check and setting the Host header via a variable, it doesn't respect the context within the location block.

 

server {
  listen 8080;
  server_name localhost;
  
  set $proxy_host $host;
  proxy_set_header Host $proxy_host;

  location /api/notworking {
    # Set host for just this block only
    set $proxy_host "override-api-not-working.host.com";

    # proxy_pass gets correct "Host: override-api-not-working.host.com"
    # so below works perfectly fine
    proxy_pass http://localhost:8000;

    # !!! health_check does not get correct host here!!!
    health_check uri=/__health?from=nginx passes=3 interval=5s fails=3;
  }
}

 

 However it works just fine if you set the host via proxy_set_header

 

server {
  listen 8080;
  server_name localhost;
  
  set $proxy_host $host;
  proxy_set_header Host $proxy_host;

  location /api/working {
    # Set host for just this block only
    proxy_set_header Host "override-api-working.host.com";

    # proxy_pass gets correct "Host: override-api-working.host.com"
    # so below works perfectly fine
    proxy_pass http://localhost:8000;

    # health_check gets correct "Host: override-api-working.host.com"
    health_check uri=/__health?from=nginx passes=3 interval=5s fails=3;
  }
}

 

 

3 REPLIES 3

Leslie_Hubertus
Community Manager
Community Manager

Thanks for the heads-up/tip, @arian!

Where can I file this as a bug to NGINX Plus?

Hi @arian - apologies on the delay in my reply, I was offline for the past couple weeks with family.

For issues with F5 products (including NGINX Plus), you should file a support case with F5 Support. Here's how: K2633: Instructions for submitting a support case to F5