Serving sites
Sites are served at http://<name>.test. To use a different domain, run valet domain <domain>, for example valet domain wip. Avoid local, which belongs to mDNS: Valet won’t delegate local or localhost and falls back to /etc/hosts entries for them.
Parking a directory
Section titled “Parking a directory”valet park registers a directory. Every folder inside it becomes a site named after the folder:
cd ~/sitesvalet parkNow ~/sites/blog is served at http://blog.test, ~/sites/shop at http://shop.test, and so on. Pass a path to park another directory without changing into it: valet park ~/work.
On systems where Valet uses /etc/hosts for name resolution, run valet restart hosts after creating a new project folder, so its name resolves. See DNS.
| Command | Effect |
|---|---|
valet paths |
List the parked directories. |
valet forget [path] |
Stop serving a parked directory. |
Linking a single project
Section titled “Linking a single project”To serve one project without parking its parent directory, link it:
cd ~/projects/apivalet link # http://api.testvalet link backend # http://backend.test| Command | Effect |
|---|---|
valet links |
List all links. |
valet unlink [name] |
Remove a link. |
Securing sites with HTTPS
Section titled “Securing sites with HTTPS”Valet creates its own certificate authority and adds it to your system’s trust store and to the NSS databases browsers use. To serve a site over HTTPS with HTTP/2:
valet secure blog # https://blog.testvalet unsecure blog # back to plain HTTPvalet secured # list secured sitesProxying a local port
Section titled “Proxying a local port”To give a Node app, a Docker container or anything else listening on a local port a Valet domain:
valet proxy app http://localhost:3000 --secure # https://app.testvalet proxies # list proxiesvalet unproxy appOpening and sharing
Section titled “Opening and sharing”| Command | Effect |
|---|---|
valet open [domain] |
Open the current (or given) site in your browser. |
valet which |
Show which driver serves the current directory. |
valet share |
Share the current site on a public URL through ngrok. |
valet fetch-share-url |
Print the URL of the running ngrok tunnel. |
valet ngrok-auth <token> |
Store your ngrok auth token. Sharing needs an ngrok account. |
Sharing on your local network
Section titled “Sharing on your local network”Valet’s Nginx listens on all network interfaces, so other devices on your network can reach your sites through nip.io, a public DNS service that resolves a name containing an IP address to that address. Find your machine’s LAN address with ip -4 addr, then open the site at http://<site>.<address>.nip.io from another device:
http://blog.192.168.1.20.nip.ioValet recognises the .nip.io suffix and serves the blog site. This needs:
- the other device to reach nip.io’s DNS (or your router to pass such lookups on),
- your firewall to allow incoming connections on port 80.
This serves sites over plain HTTP, secured ones included, because Valet’s certificates are only for .test names and only your machine trusts them. For an HTTPS link, use valet share.
Valet listens on ports 80 and 443. To change them:
valet port 8080 # HTTPvalet port 8443 --https # HTTPSWildcard subdomains
Section titled “Wildcard subdomains”Where Valet can delegate its domain through systemd-resolved, any subdomain of a site works too: api.blog.test reaches blog.test. Otherwise only the exact site names resolve. See DNS for when each applies.