paul degrand
paul degrand

Reputation: 385

targeting dev sites with vhost setup using ngrok

I'm trying to tunnel a clients site in my sites directory with "ngrok http -host-header = client1.dev 80", I get a 404 when accessing the url. After some experimenting, if I put an index.html file in the home directory, it will display that file. Not sure why a file in the home directory works while files in sites directory do not. I must be missing something here..Any ideas?

directory structure :

www
  |home
  |sites
    | client1
    | client2
      ... 

vhost.conf :

<Directory "/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<Virtualhost *:80>
VirtualDocumentRoot "/Users/myname/www/home/wwwroot"
ServerName home.dev
UseCanonicalName Off
</Virtualhost>

<Virtualhost *:80>
VirtualDocumentRoot "/Users/myname/www/sites/%1/wwwroot"
ServerName sites.dev
ServerAlias *.dev
UseCanonicalName Off
</Virtualhost>

Upvotes: 37

Views: 26265

Answers (4)

Abdourahmane FALL
Abdourahmane FALL

Reputation: 1917

Cool All your config is good, You just have to exec command

ngrok http -host-header=rewrite home.dev:80

ngrok http -host-header=rewrite sites.dev:80

New Command (8-30-22 edit):

ngrok http --host-header=rewrite sites.dev:80

Upvotes: 100

Harish ST
Harish ST

Reputation: 1503

Not sure if the command got changed from the previous versions.

From the help doc of Ngrok,

ngrok http --host-header=ex.com 80          # rewrite the Host header to 'ex.com'

Notice the double hyphens(--).

Upvotes: 2

Diogo Gomes
Diogo Gomes

Reputation: 2265

For me it only worked with:

ngrok http -host-header=sites.dev 80

Change sites.dev to you virtual host name

Source: Virtual hosts (MAMP, WAMP, etc)

Upvotes: 43

Alex McCabe
Alex McCabe

Reputation: 1892

If you want a more permanent configuration, you can edit your ~/.ngrok2/ngrok.yml config file.

tunnels:
  test: # the name of your tunnel to call from the command line
    addr: 80 # Your localhost port
    proto: http
    host_header: test.localhost # Your localhost virtualhost

And then you can run from your command line

ngrok start test

Upvotes: 6

Related Questions