docker-ngrok icon indicating copy to clipboard operation
docker-ngrok copied to clipboard

Unable to hit /api/tunnels when running using a configuration file

Open esune opened this issue 2 years ago • 2 comments

I am trying to start-up an ngrok instance and query the /api/tunnels endpoint to fetch settings for downstream services. When running docker-ngrok using a configuration file, the /api/tunnels endpoint as well as the webUI are not visible/usable on the exposed port on the host.

Example:

  • docker-compose.yaml proxying requests to services running in docker
version: "3"
services:
  ngrok:
    image: ngrok/ngrok
    environment:
      - NGROK_CONFIG=/etc/ngrok.yml
      - NGROK_AUTHTOKEN=<token-here>
    volumes:
      - ./ngrok.yml:/etc/ngrok.yml
    ports:
      - 4056:4040
  • ngrok.yml
version: "2"
tunnels:
    service1:
        addr: service1:5000
        proto: http
        schemes:
            - https
    service2:
        addr: service2:8030
        proto: http
        schemes:
            - https

In the folder where the above docker-compose.yaml and ngrok.yml are located, open a shell and execute docker compose up -d.

The container will start, no logs will be visible. Going to http://localhost:4056 will return a connection error, same when querying the /api/tunnels endpoint.

Using a slightly modified image (to add curl, see following Dockerfile) the result is the same, however attaching a terminal to the container and executing curl http://localhost:4040/api/tunnels returns the correct payload.

FROM ngrok/ngrok:debian

USER root

RUN apt-get -y update; apt-get -y install curl

USER ngrok

Using the following docker-compose.yaml that instead starts ngrok using a command-line argument works as expected (UI exposed to http://localhost:4056 and configuration available via API at /api/tunnels:

version: "3"
services:
  ngrok:
    image: ngrok/ngrok
    command: http 1080
    ports:
      - 4056:4040

Starting the image with a configuration file using an interactive terminal ( such as with docker run -it -p 4056:4040 -v /$(pwd)/ngrok/ngrok.yml:/etc/ngrok.yml -e NGROK_CONFIG=/etc/ngrok.yml ngrok/ngrok) still returns a connection error, however the ngrok endpoints listed in the terminal seem to work correctly (in the example above they would throw a bad gateway error if no services are running with that name/port combination).

esune avatar Feb 07 '23 21:02 esune

Also see this issue. When using NGROK_CONFIG attempting to browse anything (i.e localhost:4040) will result in an error.

$ http localhost:4040 
http: error: ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) while doing a GET request to URL: http://localhost:4040/

As soon as I switch to NGROK_AUTHTOKEN everything works as expected.

jasonhowk avatar Mar 09 '23 18:03 jasonhowk

Bumping this: I'd like to switch some services over to the new (maintained) image, but this is currently preventing us from using it

esune avatar May 04 '23 22:05 esune