How to create virtual host

Hello,
I would like to implement virtual host as explained here:

Icinga 2 Config Language (DSL): Advanced Apply Rules

I don’t understand if could I create it from Director.

Could anyone suggest me how to create it?

How to create http_vhosts by means of Director?
Is it an array?

Thanks a lot
Mario

cinga Web 2 Version
2.9.3
Git commit
c757a17530c326c7d6daebd6171486cb8167a8a1
PHP Version
7.2.24-0ubuntu0.18.04.10
Git commit date
2021-08-10
Director 1.8.1

If I understand correctly, this is currently not possible with the director.

Hi,
I read about the “Service apply rule” but my problem is the object “reverse-proxy-1”

How to create it from Director

object Host "reverse-proxy-1" {
  import "generic-host"
  address = "10.0.10.5"

  vars.http_vhosts = {
    "icingaweb2" = {
      vhost = "icinga.domain.com"
      ssl = true
    }
    "grafana" = {
      vhost = "grafana.domain.com"
      ssl = true
    }
    "api_v1" = { 
      vhost = "api.domain.com" 
      ssl = true
      uri = "/v1"
    }
    "api_v2" = {
      vhost = "api.domain.com" 
      ssl = true
      uri = "/v2"
    }
    "status" = {
      vhost = "status.domain.com"
    }
  }
}

I don’t understand how to create the vars mentioned there

You can’t (afaik).
The Director does not cover 100% of the Icinga DSL, the configuration language, used in the config files.
If you want advanced service configuration or functions you will have to define them in the config files and put them somewhere under /etc/icinga2/zones.d

1 Like

I created inside:
/etc/icinga2/conf.d

a file:
myobject_service.conf with inside the specification vhost and service apply and they work.

Is it possible to import into Director so I could manage them from Director?

Thanks a lot
Mario

AFAIK, not at the moment but you could manage the service template and utilized check command that is imported in your service apply rule via director.

But the service template needs to have the array host.vars.http_vhosts populated with vhost and ssl but the populated field can’t be read by Director because the object Host “reverse-proxy-1” is not inside it.

So it seems that I can’t use the “Service Template” from Director too.

The director has no knowledge of you service apply config and your hosts but your service apply config and your host can use stuff in director global. So you can manage some stuff in the director and use it in your handwritten config.

1 Like

I understood bad, because I thought you said the opposite.

yes, my handwritten config already use object inside the Director (gropus, generic-host template, notification)

Thanks a lot

1 Like

Maybe I’m out of date, have a look at why it isn’t a good idea and follow the rabbit hole:

1 Like