Skip to content

Commit 6d4eff8

Browse files
author
Lars T Hansen
committed
Doc
1 parent 3b35662 commit 6d4eff8

2 files changed

Lines changed: 45 additions & 13 deletions

File tree

doc/HOWTO-KAFKA.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,46 @@ If the nodes running Sonar are behind an http proxy then the Kafka broker cannot
217217
directly, but must be contacted through a Kafka proxy that accepts the data via an http REST call
218218
and forwards them to the broker. The proxy in `util/kafka-proxy` can be used for this and Sonar
219219
knows how to talk to it. In this case, configure the `[kafka]` section of Sonar's config with a
220-
`rest-endpoint` instead of a `broker-address` and leave out the `ca-file`. Run the proxy behind a
221-
web server, eg, for nginx I use this:
220+
`rest-endpoint` instead of a `broker-address`. The 8090 port is the default for the proxy.
221+
222+
On the backend, there are two possible configurations, one for a standard TLS certificate on a host
223+
with a well-known name, one one for use with self-signed certificates for other setups.
224+
225+
Note in the following that there are two .ini files, one for Sonar on the nodes and one for the
226+
Kafka proxy on the backend. Both of those have `[kafka]` and `[http]` sections. Do not confuse
227+
them.
228+
229+
### Well-known host names, standard cert
230+
231+
A host such as `naic-monitor.uio.no` has a fully qualified, globally visible name, and a cert from a
232+
normal CA. In this case, Sonar on the cluster nodes is configured *without* a `kafka.ca-file`
233+
property but *with* an HTTPS `kafka.rest-endpoint`. On the backend, a standard web server takes
234+
care of TLS and forwards traffic over plain HTTP to the kafka proxy that runs on the backend but is
235+
not externally visible. For example, for nginx I use this:
222236

223237
```
224238
location /kprox {
225239
proxy_pass http://localhost:8090;
226240
}
227241
```
228242

229-
and set up the `rest-endpoint` to be `https://my-kafka-host.uio.no/kprox`. The 8090 port is the
230-
default for the proxy. Then the ini file *for the proxy* is usually pretty simple, these values are
231-
exactly those that were used in the Sonar config file when it was speaking directly to the Kafka
232-
broker:
243+
For Sonar on the cluster nodes, I set up the corresponding `rest-endpoint` to be
244+
`https://my-kafka-host.uio.no/kprox`.
245+
246+
### Private or no host name, self-signed cert
247+
248+
For test setups or hosts that have no names or at least not globally or organization-wide visible
249+
names, a self-signed certificate can be used for HTTPS. In this case we have two files, the server
250+
certificate (call it sonar-ca.crt) and the secret key (sonar-ca-key.pem). The certificate is not
251+
secret and is distributed to all the cluter nodes. For Sonar, `kafka.ca-file` is set to point to
252+
that file, along with a `kafka.rest-endpoint` using HTTPS (as above). On the proxy, the
253+
`http.ca-file` points to the server certificate and `http.key-file` points to the secret key. This
254+
is sufficient for Sonar and the proxy to be communicating over HTTPS.
255+
256+
### Proxy-to-Kafka communication
257+
258+
Then the ini file for the proxy is usually pretty simple, these values are exactly those that were
259+
used in the Sonar config file when it was speaking directly to the Kafka broker:
233260

234261
```
235262
[kafka]

util/kafka-proxy/kprox.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
2+
//
33
// Copyright (c) 2023-2026 Norwegian Ai Cloud
44

55
// Kprox is a very simple Kafka REST proxy, written for Sonar but probably generally useful.
@@ -25,20 +25,25 @@
2525
//
2626
// # Config file
2727
//
28-
// The config file is on .ini format with http, kafka, and debug sections:
28+
// The config file is on .ini format with http, kafka, and debug sections, all settings have
29+
// defaults.
30+
//
31+
// The http section configures the connection between the remote Sonar and the proxy:
2932
//
3033
// [http]
3134
// endpoint = ... # default /
3235
// listen-port = ... # default 8090
33-
// ca-file = ... # default ""
34-
// key-file = ... # default ""
36+
// ca-file = ... # default ""
37+
// key-file = ... # default ""
3538
//
3639
// The proxy listens on for incoming traffic the interface ":{http.listen-port}{http.endpoint}",
3740
// by default ":8090/".
3841
//
3942
// If http.ca-file has a value then http.key-file must also have a value (and vice versa), and
4043
// the proxy will listen for https traffic only, using that information.
4144
//
45+
// The kafka section configures the connection between the proxy and the Kafka broker:
46+
//
4247
// [kafka]
4348
// broker-address = ... # default localhost:9099
4449
// ca-file = ... # default none
@@ -53,16 +58,16 @@
5358
//
5459
// kafka.timeout is how long to hold messages without broker contact before discarding them.
5560
//
56-
// If -D is present, the [debug] section is honored:
61+
// The [debug] section is honored if -D is present on the command line:
5762
//
5863
// [debug]
5964
// dump = filename
6065
// user = username
6166
// password = password
6267
//
6368
// If there is a debug.dump, all validated incoming data are appended to that file. If there are
64-
// debug.user and/or debug.password then the sasl-user / sasl-password fields must be set in the
65-
// control object and must match the user / password or the message is rejected, not dumped.
69+
// debug.user and/or debug.password properties then the sasl-user / sasl-password fields must be set
70+
// in the control object and must match the user / password or the message is rejected, not dumped.
6671
//
6772
// # Protocol
6873
//

0 commit comments

Comments
 (0)