From d5dc32d3b3625c6a849c6569ab28c1010d044335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Miri=C4=87?= Date: Thu, 22 Dec 2022 17:20:46 +0100 Subject: [PATCH] Add documentation for new wildcard Hosts feature This documents support for using a wildcard with the `hosts` option, which was recently added in v0.42.0. See https://github.com/grafana/k6/pull/2747. --- .../en/02 Using k6/05 k6 Options/02 Reference.md | 8 +++++--- .../translated-guides/es/02 Using k6/05 Options.md | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/data/markdown/translated-guides/en/02 Using k6/05 k6 Options/02 Reference.md b/src/data/markdown/translated-guides/en/02 Using k6/05 k6 Options/02 Reference.md index 4e3caf96c5..7cab22e818 100644 --- a/src/data/markdown/translated-guides/en/02 Using k6/05 k6 Options/02 Reference.md +++ b/src/data/markdown/translated-guides/en/02 Using k6/05 k6 Options/02 Reference.md @@ -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`.
@@ -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 }, }; ``` -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 diff --git a/src/data/markdown/translated-guides/es/02 Using k6/05 Options.md b/src/data/markdown/translated-guides/es/02 Using k6/05 Options.md index a4888b5160..3712012d2c 100644 --- a/src/data/markdown/translated-guides/es/02 Using k6/05 Options.md +++ b/src/data/markdown/translated-guides/es/02 Using k6/05 Options.md @@ -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á. @@ -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 }, }; ``` -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