Skip to content

Add relay and discovery Dockerfiles - #6143

Merged
calmh merged 2 commits into
syncthing:masterfrom
jyundt:add-relay-disco-dockerfiles
Nov 11, 2019
Merged

calmh merged 2 commits into
syncthing:masterfrom
jyundt:add-relay-disco-dockerfiles

Conversation

@jyundt

@jyundt jyundt commented Nov 9, 2019

Copy link
Copy Markdown
Contributor

Purpose

Add Dockerfiles for discovery and relay servers. Both files are mostly copy/pasta-ed from the existing syncthing Dockerfile. I slightly modified the entrypoint to allow for reuse between all three images.

This is a follow-up to #6014.

Testing

I've been running containers based on these Dockerfiles:

@jyundt jyundt changed the title Add relay disco dockerfiles Add relay and discovery Dockerfiles Nov 9, 2019

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the discosrv require host networking? It depends on being able to see the source address of the announcing device and I’d expect the Docker proxy obscures this

@jyundt

jyundt commented Nov 9, 2019

Copy link
Copy Markdown
Contributor Author

Does the discosrv require host networking? It depends on being able to see the source address of the announcing device and I’d expect the Docker proxy obscures this

Based on my testing: no, host networking isn't required.

However, I have the discovery server behind an Ingress router (ingress-nginx) with the following annotations:

annotations:
  nginx.ingress.kubernetes.io/server-snippet: |
    ssl_verify_client optional_no_ca;
  nginx.ingress.kubernetes.io/configuration-snippet: |
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-SSL-Cert $ssl_client_cert;

I also had to add the other misc relay/disco ports (22000, 22067, 22070, 19200) to the tcp-services config map as well.

@calmh

calmh commented Nov 10, 2019

Copy link
Copy Markdown
Member

Right, so the discovery server picks up x-forwarded-for and makes this work, but I don't think that will be the case in general when someone tries to deploy this, so it requires notes or some workaround I think.

@jyundt

jyundt commented Nov 10, 2019

Copy link
Copy Markdown
Contributor Author

Can you provide more details about the deployment scenario you'd like me to test / document?

I ran the discovery container in docker (no kubernetes), pointed a few clients to it and I think it's working as expected.

I ran the following on a server:

$ docker run --rm -p 8443:8443 jyundt/stdiscosrv "-debug"
stdiscosrv v1.3.0+63-g59e83a58-add-relay-disco-dockerfiles "Fermium Flea" (go1.13.4 linux-amd64) [email protected] 2019-11-09 16:14:37 UTC
Failed to load keypair. Generating one, this might take a while...
Server device ID is 57OEPHJ-344DNTM-SZVYPM6-3VZWPWH-3HGWX4H-MJPQKRZ-6OOIQXF-M35KBQ2

And then pointed some clients to: https://$myserver:8443/?id=57OEPHJ-344DNTM-SZVYPM6-3VZWPWH-3HGWX4H-MJPQKRZ-6OOIQXF-M35KBQ2

However, in ^this config I am getting some http: TLS handshake error errors that I didn't encounter when running in k8s / with an ingress router:

380704bb7b4d7c03 POST /
57e9d1860d1d68d8 GET /?device=P42J27W-AWBSYRR-GQLLGQL-#######-#######-#######-#######-#######
1408d2ac22c4d294 GET /?device=RJ4WSBH-LB74VTJ-GIKRFLM-#######-#######-#######-#######-#######
268447a4189deb99 GET /?device=VTFCKKH-5MMDF5N-56YRCYZ-#######-#######-#######-#######-#######
68255aaf95e94627 GET /?device=WPLPF7N-KGEAOTB-7ZWEMXC-#######-#######-#######-#######-#######
http: TLS handshake error from 127.0.0.1:33911: EOF
http: TLS handshake error from 127.0.0.1:45105: EOF
30b95ff183c471d4 GET /?device=HH4N4UC-EGQOB5S-EMCQ3PA-#######-#######-#######-#######-#######
3c04951aa42655d9 GET /?device=P42J27W-AWBSYRR-GQLLGQL-#######-#######-#######-#######-#######
25845c95d4491d1b GET /?device=RJ4WSBH-LB74VTJ-GIKRFLM-#######-#######-#######-#######-#######
1bf98be2a9d78d73 GET /?device=VTFCKKH-5MMDF5N-56YRCYZ-#######-#######-#######-#######-#######
2e3108dabb158644 GET /?device=WPLPF7N-KGEAOTB-7ZWEMXC-#######-#######-#######-#######-#######
6e661e92759805f5 POST /
2606cd2b57d29245 GET /?device=HH4N4UC-EGQOB5S-EMCQ3PA-#######-#######-#######-#######-#######
1a714cf86b83d0e2 GET /?device=P42J27W-AWBSYRR-GQLLGQL-#######-#######-#######-#######-#######
592e17f7b068d9db GET /?device=RJ4WSBH-LB74VTJ-GIKRFLM-#######-#######-#######-#######-#######
039f6f78a15d523b GET /?device=WPLPF7N-KGEAOTB-7ZWEMXC-#######-#######-#######-#######-#######
4dba7b0f9da1d7eb GET /?device=3BL666K-27RHZMZ-PMLFSSW-#######-#######-#######-#######-#######
http: TLS handshake error from 127.0.0.1:39101: EOF

Were you thinking about a deployment scenario that is kubernetes / no ingress router?

@AudriusButkevicius

AudriusButkevicius commented Nov 10, 2019 •

Copy link
Copy Markdown
Member

Can you hit it from a remote machine with no k8s?

http: TLS handshake error from 127.0.0.1:33911: EOF shows local address, which is not clear if it's because of docker proxy or because of local routing rules. If it's because of docker proxy, then this doesn't work, as we rely on the network stack to report correct callers IPs.

@jyundt

jyundt commented Nov 10, 2019

Copy link
Copy Markdown
Contributor Author

Can you hit it from a remote machine?
http: TLS handshake error from 127.0.0.1:33911: EOF shows local address, which is not clear if it's because of docker proxy or because of local routing rules.

Yes, I was hitting it from remote machines.

Upon further inspection I think this was the Docker healthcheck:

HEALTHCHECK --interval=1m --timeout=10s \
  CMD nc -z localhost 8443 || exit 1

@AudriusButkevicius

Copy link
Copy Markdown
Member

I think that's fine, but what I care whether remote IP address reported by the network stack is actually remote. It seems it is never in the logs, so you either need to modify the source code to add printing of it, or run stdiscosrv against postgres and check what gets recorded in the db.

@jyundt

jyundt commented Nov 10, 2019

Copy link
Copy Markdown
Contributor Author

I built a new discovery container with this quick-and-dirty patch:

$ git diff
diff --git a/cmd/stdiscosrv/apisrv.go b/cmd/stdiscosrv/apisrv.go
index a848ebc9..104d4925 100644
--- a/cmd/stdiscosrv/apisrv.go
+++ b/cmd/stdiscosrv/apisrv.go
@@ -129,7 +129,7 @@ func (s *apiSrv) handler(w http.ResponseWriter, req *http.Request) {
        ctx := context.WithValue(topCtx, idKey, reqID)
 
        if debug {
-               log.Println(reqID, req.Method, req.URL)
+               log.Println(reqID, req.RemoteAddr, req.Method, req.URL)
        }
 
        var remoteIP net.IP
$

The remote IP address looks fine (I think):

# docker run --rm -p 8443:8443 stdiscosrv_localhost:latest -debug
stdiscosrv v1.3.1+39-g59e83a58-dirty-add-relay-disco-dockerfiles "Fermium Flea" (go1.13.1 linux-amd64) [email protected] 2019-11-09 16:14:37 UTC
Failed to load keypair. Generating one, this might take a while...
Server device ID is NJK62PX-JJZTHIU-UW57OIR-I3JRK4W-LEHO7C6-QCQUQQA-XWHZP4Y-YCRODQI
78629a0f5f3f164f 192.168.67.137:37006 GET /?device=HH4N4UC-EGQOB5S-EMCQ3PA-#######################################
380704bb7b4d7c03 192.168.67.137:37004 POST /
57e9d1860d1d68d8 192.168.67.137:37008 GET /?device=P42J27W-AWBSYRR-GQLLGQL-#######################################
1408d2ac22c4d294 192.168.67.137:37010 GET /?device=RJ4WSBH-LB74VTJ-GIKRFLM-#######################################
268447a4189deb99 192.168.67.137:37012 GET /?device=VTFCKKH-5MMDF5N-56YRCYZ-#######################################
68255aaf95e94627 192.168.67.137:37014 GET /?device=WPLPF7N-KGEAOTB-7ZWEMXC-#######################################
http: TLS handshake error from 127.0.0.1:45695: EOF
30b95ff183c471d4 192.168.67.121:44821 GET /?device=HH4N4UC-EGQOB5S-EMCQ3PA-#######################################
3c04951aa42655d9 192.168.67.121:44823 POST /
25845c95d4491d1b 192.168.67.121:44831 GET /?device=P42J27W-AWBSYRR-GQLLGQL-#######################################
1bf98be2a9d78d73 192.168.67.121:44833 GET /?device=RJ4WSBH-LB74VTJ-GIKRFLM-#######################################
2e3108dabb158644 192.168.67.121:44835 GET /?device=WPLPF7N-KGEAOTB-7ZWEMXC-#######################################
6e661e92759805f5 192.168.67.121:44837 GET /?device=3BL666K-27RHZMZ-PMLFSSW-#######################################
http: TLS handshake error from 127.0.0.1:34657: EOF
2584c47f2cdf5b8a 192.168.67.137:37048 GET /?device=HH4N4UC-EGQOB5S-EMCQ3PA-#######################################
6054502fc5d6d268 192.168.67.137:37050 GET /?device=P42J27W-AWBSYRR-GQLLGQL-#######################################
6ec34c367674cb74 192.168.67.137:37052 GET /?device=RJ4WSBH-LB74VTJ-GIKRFLM-#######################################
430c8b35bb9457d8 192.168.67.137:37054 GET /?device=WPLPF7N-KGEAOTB-7ZWEMXC-#######################################
http: TLS handshake error from 127.0.0.1:44819: EOF

Should I add additional debugging elsewhere to double check this remote IP?

@AudriusButkevicius

Copy link
Copy Markdown
Member

No, this looks good. I am happy with this.

I'll leave for @calmh to merge given we've answered the question.

@calmh
calmh merged commit 0cc77fe into syncthing:master Nov 11, 2019
@calmh calmh added this to the v1.3.2 milestone Nov 11, 2019
calmh added a commit to calmh/syncthing that referenced this pull request Nov 11, 2019
* master:
  docker: Add stdiscosrv and strelaysrv Dockerfiles (syncthing#6143)
  lib/protocol: Buffer allocation when compressing (fixes syncthing#6146) (syncthing#6147)
  golang-ci: Upgrade, skipping the white space complainer
  all: Cleanups enabled by Go 1.12
  lib/tlsutil: Remove Go 1.12 TLS 1.3 beta opt-in
  lib/api: Make theme paths relative (syncthing#6142)
  gui, lib/api: Adds support for prefers-color-scheme (fixes syncthing#6115)
  lib/api: Reset mtime after theme change (fixes syncthing#5810) (syncthing#6140)
  lib/model: Remove some testing deadlocks (syncthing#6138)
  lib/model: Add test for previous commit
  lib/model: Add initial deviceStatRefs on model creation (fixes syncthing#6136) (syncthing#6137)
  lib/model: Add folders on start in model (syncthing#6135)
  cmd/stbench: rm -r cmd/stbench (syncthing#6131)
  lib/api: Slightly unflake TestCSRFRequired by allowing longer timeout
  Fix bufferpool puts (ref syncthing#4976) (syncthing#6125)
  all: Remove dead code, fix lost msgLen checks (syncthing#6129)
  lib/upnp: Fix outdated comment (syncthing#6110)
calmh added a commit to calmh/syncthing that referenced this pull request Nov 11, 2019
* dbastr3: (37 commits)
  docker: Add stdiscosrv and strelaysrv Dockerfiles (syncthing#6143)
  lib/protocol: Buffer allocation when compressing (fixes syncthing#6146) (syncthing#6147)
  golang-ci: Upgrade, skipping the white space complainer
  all: Cleanups enabled by Go 1.12
  lib/tlsutil: Remove Go 1.12 TLS 1.3 beta opt-in
  lib/api: Make theme paths relative (syncthing#6142)
  gui, lib/api: Adds support for prefers-color-scheme (fixes syncthing#6115)
  lib/api: Reset mtime after theme change (fixes syncthing#5810) (syncthing#6140)
  lib/model: Remove some testing deadlocks (syncthing#6138)
  lib/model: Add test for previous commit
  lib/model: Add initial deviceStatRefs on model creation (fixes syncthing#6136) (syncthing#6137)
  lib/model: Add folders on start in model (syncthing#6135)
  wip
  wip
  wip
  wip
  cmd/stbench: rm -r cmd/stbench (syncthing#6131)
  lib/api: Slightly unflake TestCSRFRequired by allowing longer timeout
  Fix bufferpool puts (ref syncthing#4976) (syncthing#6125)
  wip
  ...
calmh added a commit to calmh/syncthing that referenced this pull request Nov 17, 2019
* master:
  golang-ci: Skip "cognitive complexity" check for now
  lib/model: Prevent cleanup-race in testing (ref syncthing#6152) (syncthing#6155)
  gui: Decrease padding on the panel and modal bodies (syncthing#6153)
  lib/model: In tests prevent goroutine leaks and increase timeouts (syncthing#6152)
  lib/model: Simplify pull error/retry logic (fixes syncthing#6139) (syncthing#6141)
  docker: Add stdiscosrv and strelaysrv Dockerfiles (syncthing#6143)
  lib/protocol: Buffer allocation when compressing (fixes syncthing#6146) (syncthing#6147)
  golang-ci: Upgrade, skipping the white space complainer
  all: Cleanups enabled by Go 1.12
  lib/tlsutil: Remove Go 1.12 TLS 1.3 beta opt-in
  lib/api: Make theme paths relative (syncthing#6142)
  gui, lib/api: Adds support for prefers-color-scheme (fixes syncthing#6115)
  lib/api: Reset mtime after theme change (fixes syncthing#5810) (syncthing#6140)
  lib/model: Remove some testing deadlocks (syncthing#6138)
  lib/model: Add test for previous commit
  lib/model: Add initial deviceStatRefs on model creation (fixes syncthing#6136) (syncthing#6137)
  lib/model: Add folders on start in model (syncthing#6135)
calmh added a commit to calmh/syncthing that referenced this pull request Nov 24, 2019
…nto logsuppression

* 'logsuppression' of https://github.com/calmh/syncthing:
  wip
  golang-ci: Skip "cognitive complexity" check for now
  lib/model: Prevent cleanup-race in testing (ref syncthing#6152) (syncthing#6155)
  gui: Decrease padding on the panel and modal bodies (syncthing#6153)
  lib/model: In tests prevent goroutine leaks and increase timeouts (syncthing#6152)
  lib/model: Simplify pull error/retry logic (fixes syncthing#6139) (syncthing#6141)
  docker: Add stdiscosrv and strelaysrv Dockerfiles (syncthing#6143)
  lib/protocol: Buffer allocation when compressing (fixes syncthing#6146) (syncthing#6147)
  golang-ci: Upgrade, skipping the white space complainer
  all: Cleanups enabled by Go 1.12
  lib/tlsutil: Remove Go 1.12 TLS 1.3 beta opt-in
  lib/api: Make theme paths relative (syncthing#6142)
  gui, lib/api: Adds support for prefers-color-scheme (fixes syncthing#6115)
  lib/api: Reset mtime after theme change (fixes syncthing#5810) (syncthing#6140)
  lib/model: Remove some testing deadlocks (syncthing#6138)
  lib/model: Add test for previous commit
  lib/model: Add initial deviceStatRefs on model creation (fixes syncthing#6136) (syncthing#6137)
  lib/model: Add folders on start in model (syncthing#6135)
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Nov 11, 2020
@syncthing syncthing locked and limited conversation to collaborators Nov 11, 2020
@jyundt
jyundt deleted the add-relay-disco-dockerfiles branch January 1, 2022 22:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants