laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.49k stars 691 forks source link

Add support for proxying multiple domains at once #1437

Closed RobertBoes closed 9 months ago

RobertBoes commented 10 months ago

This PR adds support for proxying multiple domains at once with a comma separated list of domains, such as valet proxy my-domain,sub.my-domain http://127.0.0.1:8000

The change is backwards compatible, since I explode the URL by comma, if there's no comma present it works as before.

Reason for this change is working locally with Octane can be a bit frustrating. We have an app that uses multiple domains and we use Valet to proxy those domains to Octane. However, currently we'd have to run these commands:

valet proxy domain http://127.0.0.1:8000
valet proxy sub.domain http://127.0.0.1:8000
valet proxy api.domain http://127.0.0.1:8000

This not only takes a long time, Valet also restarts nginx after each command, prompting for the sudo password every time. With this change it can be done in a single command, is much faster and only restarts nginx once;

valet proxy domain,sub.domain,api.domain http://127.0.0.1:8000

It also includes the unproxy command

valet unproxy domain,sub.domain,api.domain

And this will also work if you proxied domain,api.domain and then run valet unproxy api.domain, as it will only unproxy the api.domain and keep the domain proxy

drbyte commented 10 months ago

Nice! Looks good to me.

SanderMuller commented 9 months ago

This PR would improve our QoL by a ton.

Currently we have to run the valet proxy 5 times (once for each (sub)domain) when starting Octane and run valet unproxy 5 times again when stopping octane. Each command triggers a security prompt on Mac and takes some time to execute.

Reducing this to one proxy/unproxy call per time would be really neat!

mattstauffer commented 9 months ago

Fantastic--what a great PR! Thank you!