FreedomBen / dory

Your development proxy for docker
MIT License
156 stars 24 forks source link

[Feature Request] Add support for xip.io hostnames #11

Closed ollietreend closed 7 years ago

ollietreend commented 7 years ago

It'd be really useful if dory supported xip.io virtual hostnames.

This would allow access to running containers from other devices on the LAN, which is really useful for example when testing web apps on mobile devices.

The project Varying-Vagrant-Vagrants/VVV implements this in a really nice way. A similar approach here would work well, I think.

So, for example, I could have a container running with VIRTUAL_HOST of example.docker, and my host IP address is 192.168.0.10. From a mobile device on the same network, I'd be able to access the container by going to http://example.docker.192.168.0.10.xip.io (since this would resolve to the host IP).

It looks like dory-http-proxy already binds to 0.0.0.0, so the server will be accessible from other devices on the network.

The only missing piece is adding a xip.io hostname regex to each virtual host's server_name entry in the nginx configuration. Something like this should work (inspired by VVV):

server {
    server_name example.docker ~^example\.docker\.\d+\.\d+\.\d+\.\d+\.xip\.io$;
}
ollietreend commented 7 years ago

This was easier to implement that I thought.

@FreedomBen I've created a PR in the relevant repository: FreedomBen/dory-http-proxy #2

FreedomBen commented 7 years ago

Yeah, I really like this idea. Will check out the PR, thank you!

FreedomBen commented 7 years ago

Thanks for your contribution :-)

Relevant PR has been merged, built, and pushed up to docker hub.

Dory has been updated to version 0.6.3 and now points at this image. So everything should be good to go!

ollietreend commented 7 years ago

Happy to help @FreedomBen 👍 thanks for merging it in.

It'd probably be useful to mention xip.io support in the project's README, but I didn't get around to that. If I get some time I'll put something together.