Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for proxying multiple domains at once #1437

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

RobertBoes
Copy link
Contributor

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
Copy link
Contributor

drbyte commented Aug 25, 2023

Nice! Looks good to me.

yCodeTech added a commit to yCodeTech/valet-windows that referenced this pull request Aug 28, 2023
…e Mac version

- Added `--secure` option to `proxy` command. (by mikaelpopowicz in laravel#1005)

	- Updated the proxy stub to be the unsecure proxy stub as default.
	- Added new `secure.proxy.valet.conf` stub for the secure proxy.
	- Changed the `proxyCreate` to accommodate.

- Changed `resecureForNewTld` to check for the new `secure.proxy` stub to ensure it keeps it secured when reinstalling Valet. (by ashleyshenton in laravel#1305)

- Added support for proxying multiple sites at once by separating them with commas, in both `proxy` and `unproxy` commands. (by RobertBoes in laravel#1437)

- Removed the obsolete `domain` alias for `tld` command.
- Updated docs.
@SanderMuller
Copy link

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
Copy link
Collaborator

Fantastic--what a great PR! Thank you!

@mattstauffer mattstauffer merged commit f9a9f7d into laravel:master Oct 3, 2023
@RobertBoes RobertBoes deleted the feat/proxy-multiple-domains branch October 3, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants