Proxying multiple subdomains
See original GitHub issueHi,
I’m working on a project which uses multiple subdomains for local development.
root domain example: .ecommerce.domain.local specific site domain: gb.websitename.ecommerce.domain.local asset domain: css.websitename.ecommerce.domain.local
The subdomains all resolve to the root domain because they point at the same vm ip (via hosts file entries)
I can’t get browsersync to load my site on a device using the external url unless that device is a vm running on my machine. If it’s my iPhone it fails to load.
Here’s my browsersync Gulp settings
browserSync.init({
proxy: gb.websitename.ecommerce.domain.local,
notify: false,
startPath: '/'
});
I can manage to proxy this setup via proxylocal and proxyreverse. Proxy reverse takes the site domain and uses the --rewrite-domain flag pointing to the root domain.
Any ideas what I can configure to get this working BrowerSync?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:8
- Comments:12
Top GitHub Comments
Proxying subdomains is possible with http-proxy-middleware. Get the requested domain from
req.headers.host
and replace host/port/whatever with your proxy url:To further highlight the above: for my project running a local WordPress multisite config via WAMP, I used the following slight modification of the above code by @SirAiedail and it works beautifully- in this case using any sub-domain of
wp-multisite.local
such assite1.multisite.local
by accessingsite1.localhost:3000
in the browser. I just needed to addchangeOrigin: true
as in @lukepolo’s post. Thank you for the wonderfully helpful thread!