Skip to content

Commit

Permalink
Add documentation for new wildcard Hosts feature
Browse files Browse the repository at this point in the history
This documents support for using a wildcard with the `hosts` option,
which was recently added in v0.42.0. See grafana/k6#2747.
  • Loading branch information
Ivan Mirić authored and MattDodsonEnglish committed Dec 23, 2022
1 parent aac1818 commit d5dc32d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ An object with overrides to DNS resolution, similar to what you can do with `/et
Linux/Unix or `C:\Windows\System32\drivers\etc\hosts` on Windows. For instance, you could set
up an override which routes all requests for `test.k6.io` to `1.2.3.4`.

You can also redirect only from certain ports or to certain ports.
Starting from v0.28.0, you can also redirect only from certain ports or to certain ports.

Starting from v0.42.0, you can use an asterisk (`*`) at the start of the host name, to avoid repetition. For example, `*.k6.io` would apply the override for all subdomains of `k6.io`.

<Blockquote mod="note" title="">

Expand All @@ -444,14 +446,14 @@ export const options = {
hosts: {
'test.k6.io': '1.2.3.4',
'test.k6.io:443': '1.2.3.4:8443',
'*.k6.io': '1.2.3.4', // applies for all subdomains of k6.io
},
};
```

</CodeGroup>

With the above code any request made to `test.k6.io` will be redirected to `1.2.3.4` without changing
it port unless it's port is `443` which will be redirected to port `8443`.
With the above code any request made to `test.k6.io` or any subdomains of `k6.io` will be redirected to `1.2.3.4` without changing its port, unless the port is `443` which will be redirected to port `8443`.

## HTTP debug

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ Un objeto con anulaciones de la resolución DNS, similar a lo que puede hacer co

A partir de la versión v0.28.0 también se soporta el redireccionamiento sólo desde ciertos puertos y/o hacia ciertos puertos.

A partir de la versión v0.42.0 puede utilizar un asterisco (`*`) al principio del nombre del servidor, para evitar repetición. Por ejemplo, `*.k6.io` aplicaría la anulación para todos los subdominios de `k6.io`.

> ### ⚠️ Tenga en cuenta que!
>
> Esto no modifica la cabecera HTTP Host propiamente dicha, sino hacia dónde se dirigirá.
Expand All @@ -471,13 +473,14 @@ export const options = {
hosts: {
'test.k6.io': '1.2.3.4',
'test.k6.io:443': '1.2.3.4:8443',
'*.k6.io': '1.2.3.4', // aplica para todos los subdominios de k6.io
},
};
```

</CodeGroup>

Con el código anterior cualquier petición hecha a `test.k6.io` será redirigida a `1.2.3.4` sin cambiar su puerto a menos que su puerto sea `443` que será redirigido al puerto `8443`.
Con el código anterior cualquier petición hecha a `test.k6.io` o cualquier subdominio de `k6.io` será redirigida a `1.2.3.4` sin cambiar su puerto, a menos que su puerto sea `443` que será redirigido al puerto `8443`.

## HTTP Debug

Expand Down

0 comments on commit d5dc32d

Please sign in to comment.