How to use ngrok with hosts file (laradock) - ngrok

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.

Related

Node js Application running on EC2 but not accessible in browser using Nginx

I'm a newbie to Nginx. I cannot access my Node.js application that I deploy on AWS EC2 using Nginx reverse proxy. If I do curl http://localhost:3000 I can see the application is running successfully on the server(I'm using pm2 for running node server). But when I try to access it in my browser or postman using public DNS I get the error This site can't be reached and the request gets timeout. Here's my Nginx configuration (I have followed a number of tutorials for this)
The configuration file is named nginx.conf and is in /etc/nginx/sites-enabled directory. If I do sudo nginx -t it says syntax is ok and the test is successful. Also I can see the Nginx is running using command sudo systemctl status nginx What could be the possible reason for this behaviour?
I figured it out the problem wasn't with the Nginx configuration actually I needed to allow public access for port 80 on my ec2 instance which is blocked by default. I allowed port 80 and everything is working fine. This blog helped me. Visit it for me details on how to enable port 80 for your ec2 instance.

Set GITLAB to be accessible on LAN

After many research i have not found anything...
I install GITLAB on a CentOS VM. The CentOS ip address is 192.168.100.1.
In the file /etc/gitlab/gitlab.rb, I modified the line:
external_url 'http:192.168.100.1:1234'
I executed the command 'gitlab-ctl reconfigure' and no errors appeared.
When I use Firefox, and I can access to my Gitlab with all the Centos' interfaces:
192.168.100.1:1234
127.0.0.1:1234
It is normal because when i execute 'netstat -ntlp', I can see:
tcp 0 0.0.0.0:1234 LISTEN 22222/nginx:master
What is the problem?
I cannot access to GitLAB outside from the same Network 192.168.100.1/24.
From an other VM on the same network (192.168.100.2), i can ping '192.168.100.2'. I also make an ssh connection but if I made a:
curl 192.168.100.1:1234
The result is "Time out"
Thank,
Vincent

How do I connect to a container hosted in Docker Toolbox?

I am attempting to run my ASP.NET Core 1.1 web API in a Docker container, but I cannot connect to the web API from a browser or curl. To troubleshoot, I have also brought up standard nginx and Apache httpd containers and cannot connect to these either, so I believe this is a Docker/Docker Toolbox/configuration issue rather than a problem with my application.
I'll focus on what I have done with nginx and Apache:
I am running Docker Toolbox on Windows 7 Professional, and everything seems to work as I would expect.
Docker commands all work as expected
I can access the underlying Windows filesystem
I can get the expected results from curl http://localhost (if I start the default IIS website on Windows 7)
So now I shut down IIS and run nginx in a container:
$ docker run -d -p 80:80 nginx
45bb1f373c11b820d8431de3eb3bf222d57d412de53e8625f461b62c4279e644
Docker now shows nginx running:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45bb1f373c11 nginx "nginx -g 'daemon off" 47 seconds ago Up 48 seconds 0.0.0.0:80->80/tcp, 443/tcp admiring_pike
But I cannot connect with either curl (within the Docker Toolbox command prompt) or a web browser in Windows:
$ curl http://localhost
curl: (7) Failed to connect to localhost port 80: Connection refused
I get exactly the same results if I run an Apache 2.4 (httpd) container.
Any ideas? Thanks! Peter
I have found the answer in another question here.
Because Docker Toolbox is running on a lightweight Linux VM, it has its own IP address. One needs either to map localhost to the VM using DOCKER_HOST ir access the VM via it's IP address, found using the command:
docker-machine ip default
As you are running on VM, you need to follow this docker document from here.
After that run the following command to check the IP address of your VM.
docker-machine ip default
Start the nginx and hit [ip default address]:port in the browser. It works!

ngrok: do I need have a server in my computer to run it?

I downloaded ngrok and I put in my website folder (example: documents/website).
I ran this command via command line: ./ngrok http 8888
ngrok by #inconshreveable (Ctrl+C to quit)
Tunnel Status online
Version 2.0.19/2.0.19
Web Interface http://127.0.0.1:4040
Forwarding http://299954c1.ngrok.io -> localhost:8888
but I could not open the website and I got this:
GET /favicon.ico 502 Bad Gateway
GET / 502 Bad Gateway
so I start see my ngrok just run if my MAMP its running like my apache and mysql on my localmachine tha is true?
so I turn on my MAMP on my mac and boom starts work perfect, my question is: my MAMP need to be on to my ngrok run?
yes, I found out i need any server running in my computer like: wamp, mamp, python server, so like that my page will be online too. put the ngrok file in your server folder.

Tunnel a localhost subdirectory through ngrok?

Objective: want to share a website preview using ngrok, which creates a tunnel from which my localhost can be seen with an url of something like mywebsite.ngrok.io
Problem: I use WAMP and my localhost folder looks something like this:
localhostdirectory
|-- website1
|-- website2
|-- etc
To access a website I type to localhost/website1/ in the browser, I would like to tunnel only that URL, the possible solutions would be:
Setting up a Virtual host, I would go through the hassle of manually setting up a virtual host, then I get something like website1.dev, and then I would pass it to ngrok as the host header in the HTTP request, like that:
ngrok http -host-header=website1.dev 80
I didn't understand what the host header is though, and why can't I pass a relative url like localhost/website1/, also what is the rewrite option?
Change the folder directory of my localhost to the folder of the website, I would prefer not to do that.
Is there a better way to accomplish my objective in an easier way, maybe going through WAMP aliases?
If you make do with Apache Vhost you just have to exec command
ngrok http -host-header=rewrite YOUR-LOCAL-DOMAIN:PORT
Dont forgot to edit host file for resolution #IP <-> YOUR-LOCAL-DOMAIN
I tried below way.
When I ran $ ./ngrok http 80 ngrok listen to localhost:80 which shows dashboard because apache server is running on port 80. Then I tried running subfolder in another port, which solved problem. Assume you have project in xyz and want ngrok should points it. Then do following
$ cd /opt/lampp/htdocs/xyz
$ php -S localhost:8080
Here 8080 is any unused port. localhost:8080 direct points to xyz and then open other terminal
$ ./ngrok http 8080
By doing this ngrok will listen to 8080 port were your xyz is running.
Hope this helps!!
After you set up the ngrok address to point to localhost on port 80, you can access your websites by their names.
Ex:
ngrok http -subdomain=dev 80
Access website1:
dev.ngrok.io/website1
I believe the correct syntax now for ngrok v3 is ngrok http --host-header=rewrite YOUR-LOCAL-DOMAIN:PORT
Notice the double --
https://ngrok.com/docs/guides/upgrade-v2-v3

Resources