From the ngrok docs:
To block phishing attacks using our platform, ngrok has added an interstitial page for free accounts receiving requests from browsers. When a user visits an endpoint for the first time, ngrok will serve an interstitial page letting the user know that the content is served via ngrok and that they should not enter sensitive information unless they trust the person that sent them the link. Users should only see this page once per endpoint and it can be completely bypassed by adding the
ngrok-skip-browser-warning
header to your request.
It's tedious to add this header while developing a client for the API, which is exposed behind ngrok. In some cases, e.g. using EventSource, affecting the request headers seems to be impossible.
Add a forward proxy which will add the ngrok-skip-browser-warning
header to all HTTP requests:
Run this image on the machine from where you are calling the ngrok endpoints:
$ docker run -d --rm -p 8080:80 -e NGROK_HOST=https://your-ngrok-domain.ngrok.io igops/ngrok-skip-browser-warning:latest
From now, use http://localhost:8080
as your API webroot.
For more features, consider getting the ngrok subscription.
Feel free to replace /etc/nginx/nginx.conf
with your own implementation, or use my config as a template in your managed nginx outside Docker.
A bare minimum nginx.conf
for your experiments:
events {
worker_connections 1024;
}
http {
server {
listen 80;
location / {
# regular forwarding headers
proxy_set_header X-Forwarded-For $proxy_protocol_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host your-ngrok-domain.ngrok.io;
# this line does the actual trick ๐
proxy_set_header ngrok-skip-browser-warning 1;
# add more features you need
# proxy_set_header ...
# forward!
proxy_pass https://your-ngrok-domain.ngrok.io;
}
}
}
Build a new image to test your conf:
FROM igops/ngrok-skip-browser-warning:latest
COPY my.conf /etc/nginx/nginx.conf
Run your variant:
$ docker run -d --rm -p 8080:80 -e NGROK_HOST=https://your-ngrok-domain.ngrok.io $(docker build -q /path/to/your/Dockerfile)
Feel free to contribute.
Variable | Description |
---|---|
NGROK_HOST | Mandatory. Your ngrok host, e.g. https://your-ngrok-domain.ngrok.io .Specifying a protocol is optional, https will be used by default.Any url parts after a domain name will be trimmed. |