ysbaddaden / prax

Rack proxy server for development
http://ysbaddaden.github.io/prax/
Other
475 stars 49 forks source link

Chrome can't resolve .dev domains #117

Open ysbaddaden opened 9 years ago

ysbaddaden commented 9 years ago

Chrome reimplements its own DNS resolver, and skips NSSwitch: https://code.google.com/p/chromium/issues/detail?id=117655 named Async DNS resolver. So Chrome isn't compatible with Prax, unless you use xip.io, switch the flag off (in Chrome < 41) --disable-async-dns or configure dnsmasq or bind or unbound locally.

Please not that all other browsers do work perfectly with the system configuration.

karlwilbur commented 9 years ago

Sorry, I didn't see this when I created #118.

ysbaddaden commented 9 years ago

It goes a bit further than chrome: NSSwitch is only available with glibc. Alternatives like musl don't implement it either.

ysbaddaden commented 9 years ago

Configuring dnsmasq may be a better solution than an NSSwitch extension. A simple script like the following, placed in either /etc/NetworkManager/dnsmasq.d (stock Debian/Ubuntu) or /etc/dnsmasq.d (installed resolvconf and dnsmasq manually) should do the trick:

local=/dev/
address=/dev/127.0.0.1

Installing the script will require to restart NetworkManager or dnsmasq.

ysbaddaden commented 9 years ago

I created the above script as /etc/NetworkManager/dnsmasq.d/prax and restarted NetworkManager: sudo restart network-manager. I'm now able to resolve .dev domains as 127.0.0.1 using dig, host and Chromium 41 with the Asynchronous DNS resolver enabled.

This should work on Debian, as long as the dnsmasq-base package is installed. The same should apply to Fedora (I don't know which package is required, maybe it is already installed, like for Ubuntu).

For other distributions, or if you don't use Network Manager, then installing dnsmasq will do the trick to. You should create the script in whatever the --conf-dir option for dnsmasq is pointing to, or directly in /etc/dnsmasq.conf then restart dnsmasq.

ysbaddaden commented 9 years ago

Please note that once dnsmasq is configured, the NSSwitch extension is no longer required, so it may eventually be deprecated —but kept as an alternative solution to dnsmasq.

mshappe commented 9 years ago

Implementing this actually caused both Chrome and Firefox to start reporting 'Connection Refused' instead!

gregwinn commented 8 years ago

I am using the lastest version of Chrome (48.0.2564.116) and I am getting ERR_CONNECTION_REFUSED.

I have tried the above network manager fix but with no luck.

I am using Ubuntu 15.10

h0jeZvgoxFepBQ2C commented 7 years ago

Is there an easy fix for this?

ysbaddaden commented 7 years ago

It's quite possible (if not highly probable) that the problem lies with systemd?

I personally only use the crystal version of Prax on Ubuntu Trusty and I have no problem, so I don't know.

jacksonrayhamilton commented 7 years ago

I was able to access my .dev domains on Debian 8 after running sudo apt-get install dnsmasq resolvconf. I'm not sure if this was relevant or not, but I had also restarted my computer after installing the .deb, but before running those commands.

lorenharrell commented 7 years ago

I found so much confusing information about prax on the web. Someone that really knows prax well should write a definitive guide. "sudo apt-get install dnsmasq resolvconf" did it for me. After that, just run prax. THANK YOU! (Rails 2.3.18 on Ubuntu 15.04 LTS.)

brunobrgs commented 6 years ago

How can I use .test instead of .dev ?

jacksonrayhamilton commented 6 years ago

@brunobrgs There is an open PR in the Crystal version of Prax providing that behavior: https://github.com/ysbaddaden/prax.cr/pull/68

Hopefully we can get it merged and released soon, but if you don’t want to wait then you could could compile prax.cr on that branch and use that.

brunobrgs commented 6 years ago

I change this line here: https://github.com/ysbaddaden/prax/blob/master/ext/nss_prax.c#L63 to test and installed again, it worked. Thanks