Skip to content

Commit

Permalink
Merge pull request #1501 from fluent/lynettemiles/sc-105734/update-ad…
Browse files Browse the repository at this point in the history
…ministration-http-proxy-md-fluent
  • Loading branch information
esmerel authored Nov 5, 2024
2 parents 9526d71 + 61c1c07 commit 197ba68
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 26 deletions.
68 changes: 43 additions & 25 deletions administration/http-proxy.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,81 @@
---
description: Enable traffic through a proxy server via HTTP_PROXY environment variable
description: Enable traffic through a proxy server using the HTTP_PROXY environment variable.
---

# HTTP Proxy

Fluent Bit supports configuring an HTTP proxy for all egress HTTP/HTTPS traffic via the `HTTP_PROXY` or `http_proxy` environment variable.
Fluent Bit supports configuring an HTTP proxy for all egress HTTP/HTTPS traffic
using the `HTTP_PROXY` or `http_proxy` environment variable.

The format for the HTTP proxy environment variable is `http://USER:PASS@HOST:PORT`, where:

* `USER` is the username when using basic authentication.
* `PASS` is the password when using basic authentication.
* `HOST` is the HTTP proxy hostname or IP address.
* `PORT` is the port the HTTP proxy is listening on.
- _`USER`_ is the username when using basic authentication.
- _`PASS`_ is the password when using basic authentication.
- _`HOST`_ is the HTTP proxy hostname or IP address.
- _`PORT`_ is the port the HTTP proxy is listening on.

To use an HTTP proxy with basic authentication, provide the username and password:

```bash
```text
HTTP_PROXY='http://example_user:[email protected]:8080'
```

When no authentication is required, omit the username and password:

```bash
```text
HTTP_PROXY='http://proxy.example.com:8080'
```

The `HTTP_PROXY` environment variable is a [standard way](https://docs.docker.com/network/proxy/#use-environment-variables) for setting a HTTP proxy in a containerized environment, and it is also natively supported by any application written in Go. Therefore, we follow and implement the same convention for Fluent Bit. For convenience and compatibility, the `http_proxy` environment variable is also supported. When both the `HTTP_PROXY` and `http_proxy` environment variables are provided, `HTTP_PROXY` will be preferred.
The `HTTP_PROXY` environment variable is a [standard
way](https://docs.docker.com/network/proxy/#use-environment-variables) of setting a
HTTP proxy in a containerized environment, and it's also natively supported by any
application written in Go. Fluent Bit implements the same convention. The
`http_proxy` environment variable is also supported. When both the `HTTP_PROXY` and
`http_proxy` environment variables are provided, `HTTP_PROXY` will be preferred.

{% hint style="info" %}
**Note**: The [HTTP output plugin](https://docs.fluentbit.io/manual/pipeline/outputs/http) also supports configuring an HTTP proxy. This configuration continues to work, however it _should not_ be used together with the `HTTP_PROXY` or `http_proxy` environment variable. This is because under the hood, the environment variable based proxy configuration is implemented by setting up a TCP connection tunnel via [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT). Unlike the plugin's implementation, this supports both HTTP and HTTPS egress traffic.

The [HTTP output plugin](https://docs.fluentbit.io/manual/pipeline/outputs/http) also
supports configuring an HTTP proxy. This configuration works, but shouldn't be used
with the `HTTP_PROXY` or `http_proxy` environment variable. The environment
variable-based proxy configuration is implemented by creating a TCP connection tunnel
using
[HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT). Unlike
the plugin's implementation, this supports both HTTP and HTTPS egress traffic.

{% endhint %}

# NO_PROXY
## `NO_PROXY`

Not all traffic should flow through the HTTP proxy. In this case, the `NO_PROXY` or `no_proxy` environment variable should be used.
Use the `NO_PROXY` environment variable when traffic shouldn't flow through the HTTP
proxy. The `no_proxy` environment variable is also supported. When both `NO_PROXY`
and `no_proxy` environment variables are provided, `NO_PROXY` takes precedence.

The format for the no proxy environment variable is a comma-separated list of hostnames or IP addresses whose traffic should not flow through the HTTP proxy.
The format for the `no_proxy` environment variable is a comma-separated list of
host names or IP addresses.

A domain name matches itself and all its subdomains (i.e. `foo.com` matches `foo.com` and `bar.foo.com`):
A domain name matches itself and all of its subdomains (for example, `example.com`
matches both `example.com` and `test.example.com`):

```bash
```text
NO_PROXY='foo.com,127.0.0.1,localhost'
```

A domain with a leading `.` only matches its subdomains (i.e. `.foo.com` matches `bar.foo.com` but not `foo.com`):
A domain with a leading dot (`.`) matches only its subdomains (for example,
`.example.com` matches `test.example.com` but not `example.com`):

```bash
NO_PROXY='.foo.com,127.0.0.1,localhost'
```text
NO_PROXY='.example.com,127.0.0.1,localhost'
```

One typical use case for `NO_PROXY` is when running Fluent Bit in a Kubernetes environment, where we want:
As an example, you might use `NO_PROXY` when running Fluent Bit in a Kubernetes
environment, where and you want:

* All real egress traffic to flow through an HTTP proxy.
* All local Kubernetes traffic to not flow through the HTTP proxy.
- All real egress traffic to flow through an HTTP proxy.
- All local Kubernetes traffic to not flow through the HTTP proxy.

In this case, we can set:
In this case, set:

```bash
```text
NO_PROXY='127.0.0.1,localhost,kubernetes.default.svc'
```

For convenience and compatibility, the `no_proxy` environment variable is also supported. When both the `NO_PROXY` and `no_proxy` environment variables are provided, `NO_PROXY` will be preferred.
1 change: 0 additions & 1 deletion vale-styles/FluentBit/WordList.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ swap:
Android device: Android-powered device
android: Android
API explorer: APIs Explorer
application: app
approx\.: approximately
as well as: and
authN: authentication
Expand Down

0 comments on commit 197ba68

Please sign in to comment.