|
| 1 | +--- |
| 2 | +id: http |
| 3 | +title: HTTP |
| 4 | +--- |
| 5 | + |
| 6 | +This module allows the `Security Engine` to acquire logs from an HTTP endpoint. |
| 7 | + |
| 8 | +## Configuration examples |
| 9 | + |
| 10 | +To receive logs from an HTTP endpoint with basic auth: |
| 11 | +```yaml |
| 12 | +source: http |
| 13 | +listen_addr: 127.0.0.1:8081 |
| 14 | +path: /test |
| 15 | +auth_type: basic_auth |
| 16 | +basic_auth: |
| 17 | + username: test |
| 18 | + password: test |
| 19 | +labels: |
| 20 | + type: mytype |
| 21 | +``` |
| 22 | +
|
| 23 | +To receive logs from an HTTP endpoint with headers: |
| 24 | +```yaml |
| 25 | +source: http |
| 26 | +listen_addr: 127.0.0.1:8081 |
| 27 | +path: /test |
| 28 | +auth_type: headers |
| 29 | +headers: |
| 30 | + MyHeader: MyValue |
| 31 | +labels: |
| 32 | + type: mytype |
| 33 | +``` |
| 34 | +
|
| 35 | +To receive logs from an HTTP endpoint with TLS and headers: |
| 36 | +
|
| 37 | +```yaml |
| 38 | +source: http |
| 39 | +listen_addr: 127.0.0.1:8081 |
| 40 | +path: /test |
| 41 | +auth_type: headers |
| 42 | +headers: |
| 43 | + MyHeader: MyValue |
| 44 | +tls: |
| 45 | + server_cert: server.crt |
| 46 | + server_key: server.key |
| 47 | +labels: |
| 48 | + type: mytype |
| 49 | +``` |
| 50 | +
|
| 51 | +To receive logs from an HTTP endpoint with mTLS: |
| 52 | +
|
| 53 | +```yaml |
| 54 | +source: http |
| 55 | +listen_addr: 127.0.0.1:8081 |
| 56 | +path: /test |
| 57 | +auth_type: mtls |
| 58 | +tls: |
| 59 | + server_cert: server.crt |
| 60 | + server_key: server.key |
| 61 | + ca_cert: ca.crt |
| 62 | +labels: |
| 63 | + type: mytype |
| 64 | +``` |
| 65 | +
|
| 66 | +:::info |
| 67 | +If most of cases when the logs are sent in JSON format, you can use the [`transform`](https://docs.crowdsec.net/docs/next/data_sources/intro/#transform) expression to parse the logs. |
| 68 | +::: |
| 69 | + |
| 70 | +For example, if the logs are sent in the following format: |
| 71 | +```json |
| 72 | +{ |
| 73 | + "Records": [ |
| 74 | + { |
| 75 | + "message": "test", |
| 76 | + "timestamp": "2021-01-01T00:00:00Z" |
| 77 | + } |
| 78 | + ] |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +the `transform` expression can be: |
| 83 | +```yaml |
| 84 | +transform: map(JsonExtractSlice(evt.Line.Raw, "Records"), ToJsonString(#)) |
| 85 | +``` |
| 86 | + |
| 87 | + |
| 88 | +Look at the `configuration parameters` to view all supported options. |
| 89 | + |
| 90 | +## Parameters |
| 91 | + |
| 92 | + |
| 93 | +### `listen_addr` |
| 94 | + |
| 95 | +The address to listen on (e.g., `127.0.0.1:8088`). |
| 96 | + |
| 97 | +Required. |
| 98 | + |
| 99 | +### `path` |
| 100 | + |
| 101 | +The endpoint path to listen on. |
| 102 | + |
| 103 | +:::info |
| 104 | +The request method is always `POST`. |
| 105 | +::: |
| 106 | + |
| 107 | +Optional, default is `/`. |
| 108 | + |
| 109 | +### `auth_type` |
| 110 | + |
| 111 | +The authentication type to use. |
| 112 | + |
| 113 | +Can be `basic_auth`, `headers`, or `mtls`. |
| 114 | + |
| 115 | +Required. |
| 116 | + |
| 117 | +### `basic_auth` |
| 118 | + |
| 119 | +The basic auth credentials. |
| 120 | + |
| 121 | +### `basic_auth.username` |
| 122 | + |
| 123 | +The basic auth username. |
| 124 | + |
| 125 | +Optional, to use when `auth_type` is `basic_auth`. |
| 126 | + |
| 127 | +### `basic_auth.password` |
| 128 | + |
| 129 | +The basic auth password. |
| 130 | + |
| 131 | +Optional, to use when `auth_type` is `basic_auth`. |
| 132 | + |
| 133 | +### `headers` |
| 134 | + |
| 135 | +The headers to send. |
| 136 | + |
| 137 | +Optional, to use when `auth_type` is `headers`. |
| 138 | + |
| 139 | +### `tls` |
| 140 | + |
| 141 | +TLS configuration. |
| 142 | + |
| 143 | +### `tls.server_cert` |
| 144 | + |
| 145 | +The server certificate path. |
| 146 | + |
| 147 | +Optional, to use when `auth_type` is `mtls`. |
| 148 | + |
| 149 | +### `tls.server_key` |
| 150 | + |
| 151 | +The server key path. |
| 152 | + |
| 153 | +Optional, to use when `auth_type` is `mtls`. |
| 154 | + |
| 155 | +### `tls.ca_cert` |
| 156 | + |
| 157 | +The CA certificate path. |
| 158 | + |
| 159 | +Optional, to use when `auth_type` is `mtls`. |
| 160 | + |
| 161 | +### `custom_status_code` |
| 162 | + |
| 163 | +The custom status code to return. |
| 164 | + |
| 165 | +Optional. |
| 166 | + |
| 167 | +### `custom_headers` |
| 168 | + |
| 169 | +The custom headers to return. |
| 170 | + |
| 171 | +Optional. |
| 172 | + |
| 173 | +### `max_body_size` |
| 174 | + |
| 175 | +The maximum body size to accept. |
| 176 | + |
| 177 | +Optional. |
| 178 | + |
| 179 | +### `timeout` |
| 180 | + |
| 181 | +The timeout to read the body. |
| 182 | + |
| 183 | +:::info |
| 184 | +The timeout is in duration format, e.g., `5s`. |
| 185 | +::: |
| 186 | + |
| 187 | +Optional. |
| 188 | + |
| 189 | +## DSN and command-line |
| 190 | + |
| 191 | +This datasource does not support acquisition from the command line. |
| 192 | + |
0 commit comments