0

On a public server, I have an Prometheus exporter setup. This is blocked, intentionally, by a firewall as the information should not be public.

From a separate network (my home network with dynamic IP), I wish to scrape the Prometheus exporter. The idea is to use autossh to setup an SSH tunnel, to be able to scrape the endpoint that way. I prefer to setup autossh using docker.

So far I have managed to setup a autossh docker container, with the following docker-compose:

  remote-nodeexporter:
    image: jnovack/autossh:latest
    container_name: remote-nodeexporter
    environment:
      - SSH_HOSTNAME=PUBLIC_IP
      - SSH_TUNNEL_REMOTE=19100
      - SSH_TUNNEL_LOCAL=9100
      - SSH_MODE=-L
    restart: always
    volumes:
      - /path/to/id_rsa:/id_rsa
    ports:
      - "19100:19100"

From within the container this works fine:

/ # wget localhost:19100/metrics
Connecting to localhost:19100 (127.0.0.1:19100)
saving to 'metrics'
metrics              100% |**********************************************************************************************************************************************************************************************| 75595  0:00:00 ETA
'metrics' saved

But from the host (or from other containers), I get errors:

/ # wget localhost:19100/metrics
--2020-07-07 08:53:25--  http://localhost:19100/metrics
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:19100... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

How do I correctly expose this endpoint?

Jacob
  • 3,521
  • 6
  • 26
  • 34
  • I confirm that bug. Already checked the `autossh` container and the tunnel works correctly. But if you nmap that container from another container within the same `docker-compose` project you see that the tunnel port is closed. Looks like it's some kind of firewall issue, not `autossh` itself. – Sidney de Moraes Oct 28 '20 at 16:11
  • Forgot to mention that I already [opened an issue on GitHub](https://github.com/jnovack/autossh/issues/26) for that. – Sidney de Moraes Oct 28 '20 at 16:11

0 Answers0