No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
serve.go

README.md

socketandserve

Serves sockets in a folder as subdomains of .dev.

Say you have a folder, /var/sockets, and serve some webapps on sockets in that folder, like

/var/sockets
  - myapp.sock
  - otherthing.sock

you can then

$ curl myapp.dev
...
$ curl otherthing.dev
...

Instructions

It will run on port 8080 by default, forwarding requests to http://xxx.dev to the socket xxx.sock in the directory specified by --socket-dir. The only thing left to do is to setup forwarding port 80 to port 8080.

On Ubuntu, at least, this is not too hard.

  1. $ sudo apt-get install dnsmasq resolvconf

  2. Edit /etc/dnsmasq.conf, add

address=/dev/127.0.0.1
interface=lo
no-dhcp-interface=lo
  1. Reboot.

  2. $ sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080

  3. It should work!

Stolen from https://mkrmr.wordpress.com/2011/07/15/using-dnsmasq-to-run-your-own-tld/ and http://serverfault.com/questions/112795/how-can-i-run-a-server-on-linux-on-port-80-as-a-normal-user.