ngrok not running due to proxy - http

I have ngrok installed on Ubuntu. I want to expose an application at 8080. The machine is behind a corporate proxy. I exported an environment variable http_proxy with the proxy value and tried to run the command:
./ngrok http 8080
The status remains reconnecting and the error says "Proxy Authorization required".
I have also tried it using a ngrok.yml config file with the proxy value. And specified the path of the file:
./ngrok http -config=./ngrok.yml 8080
This is how the config file looks:
console_ui: true
inspect_db_size: 50000000
log_level: debug
log_format: json
log: /var/log/ngrok.log
http_proxy: "http://username:password#proxyhost.co.in:8080"
tunnels:
jenkins:
addr: 8080
bind_tls: true
inspect: false
proto: http
Still the error persists. Inspite of specifying the correct proxy, its failing. Any help would be appreciated.

open CMD. And type this:
set http_proxy=
set https_proxy=

There should be the following entry:
authtoken: YOUR_NGROK_TOKEN
in the configuration file. Perhaps, due to its absence you get the error.
The token you can find from your ngrok-account, from dashboard.

Related

Laravel Homestead Mailhog Error listening on socket: listen tcp 0.0.0.0:1025: bind: address already in use

I am struggling to make MailHog work in my Laravel Homestead VM.
If I browse http://localhost:8025/, the web browser says it can't find it.
Then, in the command line, when executing $ mailhog, I get the following error:
Error listening on socket: listen tcp 0.0.0.0:1025: bind: address
already in use
Moreover, if I execute $ mailhog --invite-jim then I get:
2021/09/13 22:49:22 Using in-memory storage 2021/09/13 22:49:22 [SMTP]
Binding to address: 0.0.0.0:1025 [HTTP] Binding to address:
0.0.0.0:8025 2021/09/13 22:49:22 Serving under http://0.0.0.0:8025/ 2021/09/13 22:49:22 [SMTP] Error listening on socket: listen tcp
0.0.0.0:1025: bind: address already in use
Here is my .env config file
.env
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=reply#app.io
MAIL_FROM_NAME="${APP_NAME}"
Does anyone know or can shed some light how to make MailHog work?
Mailhog web interface is clearly listening at the 8025 port. The localhost or 127.0.0.1 address may not work by default.
Take a look at both the /etc/hosts and Homestead.yml file
$ sudo vim /etc/hosts
$ vim Homestead.yml
Look for the address that Homestead is working on. In this case it's 192.168.10.10 or 192.168.56.56
So now try
http://192.168.10.10:8025 or http://192.168.56.56:8025
And it should be working now

Ngrok inbuilt file server configuration through config file

Ngrok servers a folder using inbuild server when we run the following in command line
ngrok http file://<path to file>
I am trying to configure more tunnels like ssh in the same machine using config files like
tunnels:
httpbin:
proto: http
file: "//<path to file>" ##THIS IS ERROR ##
demo:
proto: ssh
addr: 22
is does not seems to be possible to configure inbuild file sharing using a configuration file in ngrok. Or is there some way?
You try this steps:
https://dashboard.ngrok.com/get-started/your-authtoken and login
Terminal and run: ngrok authtoken token_id
result: Authtoken saved to configuration file: /home/user/.ngrok2/ngrok.yml
Terminal: ngrok http file:///home
Finish !
result: https://i.stack.imgur.com/FPZbP.png
ngrok doc: https://ngrok.com/docs
Actually just stumbled across it by accident. A bit of experimentation, and no guarantees that it will continue to work since it's not mentioned in the docs. Just use the file: protocol in the addr yaml option.
authtoken: <REDACTED>
tunnels:
dev2:
proto: http
addr: file:///some/path/just/like/command/line
hostname: my-great-subdomain.ngrok.io

Port-forwarding to a local domain using socat

I'm trying to setup port forwarding from localhost to a local server using socat. The server is available via http://my-local-domain.
Here is what I tried:
socat -d -d tcp-listen:8081,reuseaddr,fork tcp:my-local-domain:80
When I open the browser and go to http://localhost:8081, I see my original localhost page, not the page when I navigate to my-local-domain.
How does one create port-forwarding to a local domain using socat?
I found that I'm not able to use Port 80 because the Host appears as localhost to NGINX, and so localhost serves the request [which would explain the original issue].
You can verify this by:
Opening nginx.conf
Adding ..."Host=$host"... to the log_format
Tailing the access logs [tail -f /usr/local/nginx/logs/access.log]
You'll notice that Host is always localhost, and so localhost serves the request.
The way to solve this is to change the Host info from localhost to my-local-server:
Localhost:8081 --> [change Host info] --> my-local-server:80
The way I found to do this was to create a proxy via Node.JS [as a go-between] as follows:
Create proxy.js
Copy the contents of the code from this gist and paste into proxy.js
Run the following command in the terminal to create proxy to web server:
PORT_LISTEN=8091 PORT_TARGET=80 HOST_TARGET="my-local-server" HOST_ORIGIN="my-local-server" node proxy.js
Run socat to proxy
socat -d -d tcp-listen:8081,reuseaddr,fork tcp:localhost:8091
So now we have the following:
Localhost:8081 --> Localhost:8091 --> my-local-server:80
This is what worked.

Kubernetes Dashboard : Dashboard keeps cancelling connection to pod, resulting in bad gateway to user

I am using kubernetes-dashboard to view all pods, check status, login, pass commands, etc. It works good, but there is a lot of connectivity issues related to it. I am currently running it on port-8443, and forwarding the connection from 443 to 8443 via Nginx's proxy pass. But I keep getting bad gateway, and connection keeps dropping. It's not an nginx issue, since I have kubernetes error. I am using Letsencrypt certificate in nginx, What am I doing wrong?
Error log :
E0831 05:31:45.839693 11324 portforward.go:385] error copying from local connection to remote stream: read tcp4 127.0.0.1:8443->127.0.0.1:33380: read: connection reset by peer
E0831 05:33:22.971448 11324 portforward.go:340] error creating error stream for port 8443 -> 8443: Timeout occured
Theses are the 2 errors I constantly get. I am running this command as a nohup process :
nohup kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard 8443:443 --address 0.0.0.0 &
And finally my nginx config :
default :
location / {
proxy_intercept_errors off;
proxy_pass https://localhost:8443/;
}
Thank you. :-)
Unfortunately this is an on-going issue with Kubernetes' port forwarding. You may find it not particularly reliable when used for long-running connections. If possible, try to setup a direct connection instead. A more extended discussion regarding this can be found here and here.

How to use ngrok with hosts file (laradock)

I am using Laradock to develop locally and so have an entry in the hosts file.
How can I get this working with ngrok?
I tried:
ngrok http -host-header=site.test 80
(https://helgesverre.com/blog/expose-local-webserver/)
but get: Failed to complete tunnel connection
(site.test works)
I got this working by running ngrok on the host machine instead of the container.

Resources