# Set ip on http monitors like curl resolve command

**URL:** https://discuss.elastic.co/t/set-ip-on-http-monitors-like-curl-resolve-command/319346
**Category:** Beats
**Tags:** heartbeat
**Created:** [November 19, 2022, 5:54pm UTC](https://discuss.elastic.co/t/set-ip-on-http-monitors-like-curl-resolve-command/319346 "2022-11-19T17:54:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![oofbird](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oofbird/32/113541_2.png) [@oofbird](https://discuss.elastic.co/u/oofbird)
#### Post date: [November 19, 2022, 5:54pm UTC](https://discuss.elastic.co/t/set-ip-on-http-monitors-like-curl-resolve-command/319346/1 "2022-11-19T17:54:56Z")

</div>

I want to monitor https service. (domain - VIP - webserver)  
testing domain(VIP) is clear. just call "[https://domain](https://domain)".

but testing webserver has a problem, guessing from SNI(Server Name Indication).  
Calling "[https://webserver](https://webserver)" returned "unexpected EOF"

in curl command, there is a option, "--resolve domain:ip" for chaning ip for domain.  
so how to set .yml like "curl --resovle" command?

---

<div class="post-metadata">

### Author: ![emilioalvap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emilioalvap/32/99310_2.png) [@emilioalvap](https://discuss.elastic.co/u/emilioalvap)
#### Post date: [November 21, 2022, 4:59pm UTC](https://discuss.elastic.co/t/set-ip-on-http-monitors-like-curl-resolve-command/319346/2 "2022-11-21T16:59:48Z")

</div>

Hi @oofbird,

There are a few alternatives, depending on the setup:

- First I'd make sure it's a SNI problem, does `curl <IP> --resolve <domain>` work as expected?
- What's the response from VIP like, cached content or redirections? If it's a redirect, you could configure [max\_redirects](https://www.elastic.co/guide/en/beats/heartbeat/current/monitor-http-options.html#monitor-http-max-redirects) and heartbeat will follow them to the end server.

Hearbeat does not support custom SNI negotiation at the moment, it uses provided host for the request. I know it's not ideal but, if you don't need to perform tls verification on the webserver, you can skip SNI by setting `ssl.verification_mode: none` and setting request `Host` headers . Something like this:

```yaml
urls: ["https://<my server ip>"]
  check.request:
    method: GET
    headers:
      Host: "<my domain>"
      X-Forwarded-Host: "<my domain>"
  ssl.verification_mode: none

```

---

<div class="post-metadata">

### Author: ![oofbird](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oofbird/32/113541_2.png) [@oofbird](https://discuss.elastic.co/u/oofbird)
#### Post date: [November 22, 2022, 6:46am UTC](https://discuss.elastic.co/t/set-ip-on-http-monitors-like-curl-resolve-command/319346/3 "2022-11-22T06:46:31Z")

</div>

Thx with reply.

`curl -X GET https://test.domain.com:1443 --resolve test.domain.com:1443:123.123.123.123` retured 'HTTP 200 OK'

But, `curl -X GET https://123.123.123.123:1443` returned 'OpenSSL SSL\_connect: SSL\_ERROR\_SYSCALL'.  
ignore option in `curl` was same. (curl version 7.64.0)  
(in curl Version 7.29.0, it returned 'Encountered end of file)

I`m not sure, but there is a problem with TLS handshake...

running `curl --resovle` with verbose, it said

```auto
Added test.domain.com:1443:123.123.123.123 to DNS cache
Hostname test.domain.com was found in DNS cache
   Trying 123.123.123.123...

```

is there a function liked this?

---

<div class="post-metadata">

### Author: ![emilioalvap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emilioalvap/32/99310_2.png) [@emilioalvap](https://discuss.elastic.co/u/emilioalvap)
#### Post date: [November 22, 2022, 11:05am UTC](https://discuss.elastic.co/t/set-ip-on-http-monitors-like-curl-resolve-command/319346/4 "2022-11-22T11:05:32Z")

</div>

Hi @oofbird,

I'd say curl output confirms it's SNI.

Unfortunately, heartbeat does not have a simil `--resolve` option atm. If you'd like to see this feature added to heartbeat, I'd like to ecourage you to open an [enhancement request over our beats repo](https://github.com/elastic/beats/issues/new/choose) and we will be able to analyze it internally.

In the mean time,there might be ways to work around this limitation, with some caveats. For one, you could disable tls verification in `heartbeat.yml` for that specific monitor. This is an example:

```yaml
- type: http
  id: my-monitor
  name: My Monitor
  schedule: '@every 10s'
  urls: ["https://<my webserver ip>"]
  ssl.verification_mode: none
  check.request:
    method: GET
    headers:
      Host: "<my SNI domain>"
      X-Forwarded-Host: "<my SNI domain>"

```

With `ssl.verification_mode: none` and `check.request.headers`, heartbeat will bypass SNI and request the correct domain from the end server. On the other hand, it won't verify server's certificate validity, so that information won't be attached to the monitor result.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 20, 2022, 1:05pm UTC](https://discuss.elastic.co/t/set-ip-on-http-monitors-like-curl-resolve-command/319346/5 "2022-12-20T13:05:44Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
