Coder Social home page Coder Social logo

Comments (7)

kunimasu avatar kunimasu commented on June 10, 2024 1

How about try addr: host.docker.internal:8080 ?

In my case, if I set addr: 8080, 502 Bad Gateway shows me. But host.docker.internal:8080 is working for my case.

from docker-ngrok.

Jawabiscuit avatar Jawabiscuit commented on June 10, 2024 1

Awesome! That worked, thankyou!

So, literally that setup above with nginx works simply by modifying ngrok.yml, replacing addr: 8080 with addr: host.docker.internal:8080 like @kunimasu suggested. So now you have a simple example!

from docker-ngrok.

Jawabiscuit avatar Jawabiscuit commented on June 10, 2024

I see there is https://ngrok.com/docs/using-ngrok-with/docker/ which has a section for compose, however I'm having a heck of a time trying to network an nginx and ngrok service defined in the same docker-compose.yml.

I don't have any issues running ngrok on the command line outside of docker-container though. Can the doc be updated with a non-trivial use-case?

from docker-ngrok.

russorat avatar russorat commented on June 10, 2024

@Jawabiscuit thanks for commenting here. I added that docker compose example to our docs recently. Can you post what you've tried here and we can debug and add it to the docs?

from docker-ngrok.

Jawabiscuit avatar Jawabiscuit commented on June 10, 2024

Yeah sure,

My setup:

Windows 10
WSL2 Ubuntu 22.04
Docker Desktop 4.17.1
Docker version 20.10.23
Compose V2

I was attempting to use ngrok to help self-serve Drone for testing out as a CI/CD solution with GitHub. It's a bit experiemental so I'm not hosting it on external infrastructure yet. I had started a docker-compose.yml already with Drone and a Drone runner setup and I saw the example so I thought i'd drop it in and see if it was possible.

After getting 502 errors consistently, I decided to make a simplified use-case.

docker-compose.yml

version: '3'

services:
  ngrok:
    image: ngrok/ngrok:latest
    restart: unless-stopped
    environment:
      NGROK_AUTHTOKEN: ${NGROK_AUTHTOKEN}
    command:
      - "start"
      - "--all"
      - "--config"
      - "/etc/ngrok.yml"
    volumes:
      - ./ngrok.yml:/etc/ngrok.yml
    ports:
      - 4040:4040
    depends_on:
      - nginx
  nginx:
    image: nginx:latest
    ports:
      - 8080:80

ngrok.yml

version: 2
tunnels:
  drone:
    proto: http
    addr: 8080
    hostname: drone.cghijinks.com

I'm using a .env for the NGROK_AUTHTOKEN.

With that setup I run docker-compose up -d. Browsing to http://localhost:8080/ shows that nginx has started up successfully. Browsing to drone.cghijinks.com I see ERR_NGROK_8012 and then to the interface at localhost:4040 I see a 502 Bad Gateway error.

I'm able to use the CLI with no problem either with a custom URL or using the generated ngrok.io one. What's pretty strange is I can't seem to background the CLI, like ngrok http 8080 &, and expect it to work either.

I've searched around the internet and I did come across someone with an earlier homebrew docker image apparently getting good results with docker-compose so I felt convinced it was possible and maybe I'm misunderstanding something or my ISP is getting in the way.

Thanks. Happy to answer any questions.

from docker-ngrok.

chinmaypurav avatar chinmaypurav commented on June 10, 2024

https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host

The reason it is failing on addr: 80 because it tried to call port 80 within that ngrok service which is absent.

I am using it on the bridge network.

  • ngrok.yml
authtoken: authtokenxxxxxxxxxxxxxxxx
version: 2
tunnels:
  your_tunnel_name:
    proto: http
    hostname: static-domain.ngrok-free.app
    addr: nginx:80
    
  • docker-compose.yml
services:
  ngrok:
    image: ngrok/ngrok:latest
    networks:
      - bridge
    command: 
      - "start"
      - "--all"
      - "--config"
      - "/etc/ngrok.yml"
    volumes:
      - ./ngrok.yml:/etc/ngrok.yml
    ports:
      - 4040:4040
  nginx:
    image: nginx:stable
    ports:
      - 80:80
      - 443:443
    networks:
      - bridge
    volumes:
      - ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - mysql
      - php

from docker-ngrok.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.