I want to access the ddev web container from another host. How can I achieve this?
For example: ddev is running on host A, I want to access the web page from host B.
Update 2024-02-23: Mostly people use ddev share
(which launches ngrok) for this in 2024. There is a full set of other options at https://ddev.readthedocs.io/en/latest/users/topics/sharing/
Original Answer
There is a good summary of techniques on https://medium.com/botfuel/how-to-expose-a-local-development-server-to-the-internet-c31532d741cc and I see a number of others - It suggests:
ddev share
or other techniques)So there are at least two variants of what you're talking about:
For either approach, we need to figure out what port to proxy.
If you can just use http, I'd proxy the localhost port (which goes directly to the web container and doesn't care what the hostname in the URL is). So if ddev describe
shows http://d7git.ddev.site:8080, https://d7git.ddev.site:8443, http://127.0.0.1:32827
, use the 127.0.0.1 port (32827 in this case). If you can do this, you won't have to fiddle with faking the hostname on the host from which you're going to access this.
So for option 1 (just exposing on another port on your machine), use any of these technqiues. I'll use the socat approach on macOS (brew install socat).
socat tcp-listen:8889,reuseaddr,fork tcp:localhost:32827
where 32827 is the port listed by ddev describe as localhost access, and 8889 is the port you want to expose to others. Then find out your local network IP address (Use ifconfig or other techniques) and others can access your ddev project with that. For example, my setup today would be http://10.150.150.87:8889/
For option 2, Proxying your project for somebody else to use on the internet, via ssh tunneling:
ssh -R :9101:localhost:32827 user@host.example.com
That will tunnel your local port 32827 (check your own ddev describe for this) to port 9101 on the remote host.example.com. Note that you'll likely have to
GatewayPorts yes
in the host's sshd config.