Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying hostname to forward request #6

Open
bkuhl opened this issue Oct 11, 2016 · 12 comments
Open

Specifying hostname to forward request #6

bkuhl opened this issue Oct 11, 2016 · 12 comments

Comments

@bkuhl
Copy link
Contributor

bkuhl commented Oct 11, 2016

I was experiencing an issue where ngrok could not access localhost:80. It looked like ngrok was trying to take an external request into the docker container and fowarding it to localhost:80 which it couldn't find.

screen shot 2016-10-11 at 12 53 29 pm

Here's an example of my not functional config:

version: '2'

services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
  ngrok:
    image: wernight/ngrok
    links:
      - web:http
    ports:
      - "4040:4040"
    env_file: .env

The solution was to tell it to forward incoming requests to web:80 and not alias the web container. Port 80 was the internal port that my web container was listening for, not the one that is publicly exposed. I was able to achieve this with the following configuration:

  ngrok:
    image: wernight/ngrok
    links:
      - web
    ports:
      - "4040:4040"
    env_file: .env
    environment:
      NGROK_PORT: web:80

In this case I happened to resolve the issue but wanted to post it here in case it was helpful to someone else.

@wernight
Copy link
Owner

May be you'd like to start a WiKi page? I've enabled it.

@walidshaari
Copy link

I got the same error, i changed the command from the example to the below:

docker run --rm -d -p 4040 --link www:http --name www_ngrok wernight/ngrok ngrok http http:80

@leewynne
Copy link

@bkuhl could you explain a little more on the following based on your solution?

env_file: .env
environment:
NGROK_PORT: web:80

@devkinetic
Copy link

NGROK_LOOK_DOMAIN should be what is used for this, but it doesn't work. Currently, using the workaround @bkuhl provided is working.

if [ -n "$NGROK_LOOK_DOMAIN" ]; then
  ARGS="$ARGS `echo $NGROK_LOOK_DOMAIN:$NGROK_PORT | sed 's|^tcp://||'`"
else
  ARGS="$ARGS `echo $NGROK_PORT | sed 's|^tcp://||'`"
fi

@bkuhl
Copy link
Contributor Author

bkuhl commented Sep 25, 2019

@madebylee Basically that's saying to read environment variables from .env, but override what's in that file with what's specified in environment.

@ezekel
Copy link

ezekel commented Jan 13, 2021

@bkuhl , should we use .env here ? or is it ok not to have ?, if ever what's inside in the .env ?

Thank you in advance

ngrok:
image: wernight/ngrok
links:
- web:http
ports:
- "4040:4040"
env_file: .env

@bkuhl
Copy link
Contributor Author

bkuhl commented Jan 13, 2021

@ezekel You should be able to use the env_file directive there just fine.

@ezekel
Copy link

ezekel commented Jan 13, 2021

@bkuhl , I rebuild my docker , my question after I rebuild is there a command to run so that it will expose now to internet ?

@ezekel
Copy link

ezekel commented Jan 13, 2021

@ezekel You should be able to use the env_file directive there just fine.

Ok I will rebuild again. thank you fro the quick reply

@ezekel
Copy link

ezekel commented Jan 13, 2021

@bkuhl, I'm done rebuilding my docker, what command to run for ngrok ?

Thank you in advance

@ezekel
Copy link

ezekel commented Jan 13, 2021

@bkuhl by the way is this will work in my local I used host in windows. then I access my app like this myapp.local, is this will work in ngrok too ?

@ezekel
Copy link

ezekel commented Jan 13, 2021

@wernight , can I ask please what command I will run so that it will generate ngrok url

Thank you in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants