typicode / hotel

🏩 A simple process manager for developers. Start apps from your browser and access them using local domains
MIT License
9.98k stars 422 forks source link

Works in browser but not in iTerm? #172

Open joegaudet opened 7 years ago

joegaudet commented 7 years ago

Hey guys,

I've got hotel configured as follows:

concierge.food
{
  "target": "http://localhost:3000"
}

And when I try and open it in the browser to concierge.food.dev, all things work just fine.

However when i try and curl concierge.food.dev, I get the following error:

curl: (7) Failed to connect to concierge.food.dev port 80: Connection refused

What am I missing?

joegaudet commented 7 years ago

Nevermind, just need to set:

export http_proxy='http://localhost:2000/proxy.pac'

joegaudet commented 7 years ago

Ok so update on the issue.

I've got a rails backend server running on http://concierge.food.dev

Then I've got ember running in dev mode on http://star-fox.dev/

The ember server is setup to proxy requests to http://concierge.food.dev by running it as such:

ember serve --proxy http://concierge.food.dev/

However inside of the running ember app the proxy fails with the same error:

Error proxying to http://concierge.food.dev/
connect ECONNREFUSED 127.0.0.1:80
Error: connect ECONNREFUSED 127.0.0.1:80
    at Object.exports._errnoException (util.js:1012:11)
    at exports._exceptionWithHostPort (util.js:1035:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
typicode commented 7 years ago

Hi @joegaudet,

Thanks for sharing the solution for curl. I would suggest trying to set proxy.pac system wide and see if it's better.

I haven't tested but the idea is to avoid having to make each tool aware of hotel.

https://github.com/typicode/hotel/tree/master/docs#system-configuration-recommended

fengb commented 7 years ago

node.js doesn't support http_proxy natively: https://github.com/nodejs/node/issues/8381

mswiszcz commented 7 years ago

@typicode have you maybe managed to make it work? I've similar setup and same problem

typicode commented 7 years ago

Hi @mswiszcz,

TBH, I didn't have much time to work on this problem. Have you tried setting the proxy auto config system-wide?

juanibiapina commented 7 years ago

Setting it system wide seems to work for curl, but not for a backend calling the other. Does it make sense?

will3216 commented 6 years ago

Hey guys, my team ran into this issue and we wrote some stuff to set up lower level network proxying. Like so:

echo "10.0.0.1 hotel.test" >> /etc/hosts
sudo ifconfig lo0 10.0.0.1 alias
sudo pfctl -ef - "rdr pass on lo0 inet proto tcp from any to 10.0.0.1 port = 80 -> 127.0.0.1 port 2000"

We run a microservice architecture, so we have dozens of apps to configure, thus we've automated this process with a config file that looks like this:

[
  {
    "host": "app-name.test",
    "name": "app_name",
    "port": "8210",
    "hotel_start_cmd": "rvm . do bundle && rvm . do bundle exec rails server -p",
    "loopback_alias": "14.0.0.1",
    "add_to_hotel": "true"
  },
  [...]
]

@typicode We are wondering what your thoughts are on adding this to base package. If you think it would be valuable we can create a PR. Let us know!