-
Notifications
You must be signed in to change notification settings - Fork 545
in_http: add_remote_addr #2130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aletourneau
wants to merge
1
commit into
fluent:master
Choose a base branch
from
aletourneau:in_http/add_remote_addr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−11
Open
in_http: add_remote_addr #2130
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,17 +5,18 @@ The _HTTP_ input plugin lets Fluent Bit open an HTTP port that you can then rout | |||||||||||||||||
|
|
||||||||||||||||||
| ## Configuration parameters | ||||||||||||||||||
|
|
||||||||||||||||||
| | Key | Description | Default | | ||||||||||||||||||
| |----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|-----------| | ||||||||||||||||||
| | `buffer_chunk_size` | This sets the chunk size for incoming JSON messages. These chunks are then stored and managed in the space available by `buffer_max_size`. | `512K` | | ||||||||||||||||||
| | `buffer_max_size` | Specify the maximum buffer size to receive a JSON message. | `4M` | | ||||||||||||||||||
| | `http2` | Enable HTTP/2 support. | `true` | | ||||||||||||||||||
| | `listen` | The address to listen on. | `0.0.0.0` | | ||||||||||||||||||
| | `port` | The port for Fluent Bit to listen on. | `9880` | | ||||||||||||||||||
| | `success_header` | Add an HTTP header key/value pair on success. Multiple headers can be set. For example, `X-Custom custom-answer`. | _none_ | | ||||||||||||||||||
| | `successful_response_code` | Allows setting successful response code. Supported values: `200`, `201`, and `204`. | `201` | | ||||||||||||||||||
| | `tag_key` | Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. | _none_ | | ||||||||||||||||||
| | `threaded` | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` | | ||||||||||||||||||
| | Key | Description | Default | | ||||||||||||||||||
| |----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|-----------| | ||||||||||||||||||
| | `add_remote_addr` | Adds a `REMOTE_ADDR` field to the record. The value of `REMOTE_ADDR` is the client's address, which is extracted from the `X-Forwarded-For` header. | `false` | | ||||||||||||||||||
| | `buffer_chunk_size` | This sets the chunk size for incoming JSON messages. These chunks are then stored and managed in the space available by `buffer_max_size`. | `512K` | | ||||||||||||||||||
| | `buffer_max_size` | Specify the maximum buffer size to receive a JSON message. | `4M` | | ||||||||||||||||||
| | `http2` | Enable HTTP/2 support. | `true` | | ||||||||||||||||||
| | `listen` | The address to listen on. | `0.0.0.0` | | ||||||||||||||||||
| | `port` | The port for Fluent Bit to listen on. | `9880` | | ||||||||||||||||||
| | `success_header` | Add an HTTP header key/value pair on success. Multiple headers can be set. For example, `X-Custom custom-answer`. | _none_ | | ||||||||||||||||||
| | `successful_response_code` | Allows setting successful response code. Supported values: `200`, `201`, and `204`. | `201` | | ||||||||||||||||||
| | `tag_key` | Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. | _none_ | | ||||||||||||||||||
| | `threaded` | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` | | ||||||||||||||||||
|
|
||||||||||||||||||
| ### TLS / SSL | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -41,6 +42,32 @@ For example, in the following curl message the tag set is `app.log` because the | |||||||||||||||||
| curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888/app.log | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Add a remote address field | ||||||||||||||||||
|
|
||||||||||||||||||
| The `add_remote_addr` configuration parameter, when activated, adds a `REMOTE_ADDR` field to the records. The value of `REMOTE_ADDR` is the client's address, which is extracted from the `X-Forwarded-For` header. | ||||||||||||||||||
|
|
||||||||||||||||||
| In most cases, only a single `X-Forwarded-For` header is in the request, so the following curl would add a `REMOTE_ADDR` field which would be set to `host1`: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```shell | ||||||||||||||||||
| curl -d '{"key1":"value1"}' -XPOST -H 'Content-Type: application/json' -H 'X-Forwarded-For: host1, host2' http://localhost:8888 | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| However, if your system sets multiple `X-Forwarded-For` headers in the request, the one used (first, or last) depends on the value of the `http2` parameter. For example: | ||||||||||||||||||
|
|
||||||||||||||||||
| Assuming the following X-Forwarded-For headers are in the request: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```text | ||||||||||||||||||
| X-Forwarded-For: host1, host2 | ||||||||||||||||||
| X-Forwarded-For: host3, host4 | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| The value of `REMOTE_ADDR` will be: | ||||||||||||||||||
|
|
||||||||||||||||||
| | http2 parameter | value of `REMOTE_ADDR` | | ||||||||||||||||||
| |------------------|------------------------| | ||||||||||||||||||
| | `true` (default) | host3 | | ||||||||||||||||||
| | `false` | host1 | | ||||||||||||||||||
|
Comment on lines
+66
to
+69
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| ### Configuration file | ||||||||||||||||||
|
|
||||||||||||||||||
| {% tabs %} | ||||||||||||||||||
|
|
@@ -161,6 +188,47 @@ pipeline: | |||||||||||||||||
| {% endtab %} | ||||||||||||||||||
| {% endtabs %} | ||||||||||||||||||
|
|
||||||||||||||||||
| #### Set `add_remote_addr` | ||||||||||||||||||
|
|
||||||||||||||||||
| The `add_remote_addr` configuration option lets you activate a feature that systematically adds the `REMOTE_ADDR` field to events, and set its value to the client's address. The address will be extracted from the `X-Forwarded-For` header of the request. The format is: | ||||||||||||||||||
|
|
||||||||||||||||||
| {% tabs %} | ||||||||||||||||||
| {% tab title="fluent-bit.yaml" %} | ||||||||||||||||||
|
|
||||||||||||||||||
| ```yaml | ||||||||||||||||||
| pipeline: | ||||||||||||||||||
| inputs: | ||||||||||||||||||
| - name: http | ||||||||||||||||||
| listen: 0.0.0.0 | ||||||||||||||||||
| port: 8888 | ||||||||||||||||||
| add_remote_addr: true | ||||||||||||||||||
| outputs: | ||||||||||||||||||
| - name: stdout | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| {% endtab %} | ||||||||||||||||||
| {% tab title="fluent-bit.conf" %} | ||||||||||||||||||
|
|
||||||||||||||||||
| ```text | ||||||||||||||||||
| [INPUT] | ||||||||||||||||||
| Name http | ||||||||||||||||||
| Listen 0.0.0.0 | ||||||||||||||||||
| Port 8888 | ||||||||||||||||||
| Add_remote_addr true | ||||||||||||||||||
|
|
||||||||||||||||||
| [OUTPUT] | ||||||||||||||||||
| Name stdout | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| {% endtab %} | ||||||||||||||||||
| {% endtabs %} | ||||||||||||||||||
|
|
||||||||||||||||||
| #### Example curl to test this feature | ||||||||||||||||||
|
|
||||||||||||||||||
| ```shell | ||||||||||||||||||
| curl -d '{"key1":"value1"}' -XPOST -H 'Content-Type: application/json' -H 'X-Forwarded-For: host1, host2' http://localhost:8888 | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| #### Set multiple custom HTTP headers on success | ||||||||||||||||||
|
|
||||||||||||||||||
| The `success_header` parameter lets you set multiple HTTP headers on success. The format is: | ||||||||||||||||||
|
|
||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.