Question

I am using Foreman specifing port 3000. How can I access my application by writting myapp.local in the browser instead of typing 0.0.0.0:3000?

I have added:

0.0.0.0  myapp.local

But when doing myapp.local it defaults to the default localhost for Apache, not the Rails app.

Was it helpful?

Solution

Short answer: You can't.

The host table is meant to map hostnames to IP addresses (Wiki). Ports come in at a different point.

However, you can specify the port Foreman should run on:

-p, --port

    Specify which port to use as the base for this application. Should be a multiple of 1000.

OTHER TIPS

I don't know the Foreman but as you connect to it with your browser than I assume it talks via HTTP. If so you can use proxy settings to point to that host:port. Try FoxyProxy. It's more like a workaround rather than a real solution but it should work (as far as it's not HTTPS)

If you're using Linux than another way is to use LD_PRELOAD to overwrite connect glibc function. It's quite low level hack but it's not so complicated.

Another way in Linux would be to make netfilter rule (iptables) to NAT the connection. It's not nice either as you'll need root level change to achieve simple thing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top