Giter VIP home page Giter VIP logo

candy's Introduction

Candy gopher_with_candy

Candy is a zero-config reverse proxy server. It makes proxying applications with local top-leveled domains as frictionless as possible. There is no messing around with /etc/hosts, Dnsmasq, or Nginx.

How does it work?

A few simple conventions eliminate the need for tedious configuration. Candy runs as your user on unprivileged ports, and includes an HTTP, an HTTPS, and a DNS server. It also sets up a system hook so that all DNS queries for a local top-level domain (.test) resolve to your local machine.

To route web traffic to an app, just create a file in the ~/.candy directory. Assuming you are developing an app that runs on http://127.0.0.1:8080, and you would like to access it at http://myapp.test, setting it up is as easy as:

$ echo "8080" > ~/.candy/myapp

The name of the file (myapp) determines the hostname (myapp.test) to access the application that it points to (127.0.0.1:8080). Both HTTP and HTTPS request is supported out of the box:

$ curl http://myapp.test
$ curl https://myapp.test

Installation

Mac

brew install owenthereal/candy/candy

After installing the candy binary, you also need to create a DNS resolver config in /etc/resolver/CONFIG. Creating the /etc/resolver directory and the config file require superuser privileges. You can execute with a one-liner:

sudo candy setup

Alternatively, you can manually execute the followings:

sudo mkdir -p /etc/resolver
cat<<EOF | sudo tee /etc/resolver/candy-test > /dev/null
domain test
nameserver 127.0.0.1
port 25353
search_order 1
timeout 5
EOF

Linux

go install github.com/owenthereal/candy/cmd/candy@latest

After installing the candy binary, you also need to create a network name resolution config in /usr/lib/systemd/resolved.conf.d/CONFIG. Creating the /usr/lib/systemd/resolved.conf.d directory and the config file require superuser privileges. You can execute with a one-liner:

sudo candy setup

Alternatively, you can manually execute the followings:

sudo mkdir -p /usr/lib/systemd/resolved.conf.d
cat<<EOF | sudo tee /usr/lib/systemd/resolved.conf.d/01-candy.conf > /dev/null
[Resolve]
DNS=127.0.0.1:25353
Domains=test
EOF
sudo systemctl restart systemd-resolved # Restart systemd-resolved

Usage

Starting Candy

Mac

To have Launchd start Candy and restart at login:

brew services start candy

To restart Candy, run:

brew services restart candy

To stop Candy, run:

brew services stop candy

Or, if you don't want/need a background service, you can just run:

candy run

Linux

TODO

Port/IP proxying

Candy's port/IP proxying feature lets you route all web traffic on a particular hostname to another port or IP address. To use it, create a file in ~/.candy with the the destination port number or IP address as its contents:

echo "8080" > ~/.candy/app1
curl https://app1.test

echo "1.2.3.4:8080" > ~/.candy/app2
curl https://app2.test

Configuration

Candy provides good defaults that most people will never need to configure it. However, if you need to adjust a setting or two, you can create a file to override the defaults in ~/.candyconfig. See this file for a list of settings that you can change.

For example, you may want to have multiple top-leveled domains besides *.test:

{
  "domain": ["test","mydomain"]
}

Changing the domain setting requires resetting DNS resolvers in /etc/resolver. Rerun the setup step and make sure all resolver config files are matching in /etc/resolver.

After changing a setting in ~/.candyconfig, you will also need to restart Candy for the change to take effect:

Prior Arts

candy's People

Contributors

dependabot[bot] avatar owenthereal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

candy's Issues

Can't install on MacOS Ventura

The output says:

$ brew install owenthereal/candy/candy

==> Tapping owenthereal/candy
Cloning into '/opt/homebrew/Library/Taps/owenthereal/homebrew-candy'...
remote: Enumerating objects: 72, done.
remote: Counting objects: 100% (72/72), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 72 (delta 16), reused 26 (delta 5), pack-reused 0
Receiving objects: 100% (72/72), 9.77 KiB | 1.40 MiB/s, done.
Resolving deltas: 100% (16/16), done.
Tapped 1 formula (13 files, 19.8KB).
Error: owenthereal/candy/candy: Calling plist_options is disabled! Use service.require_root instead.
Please report this issue to the owenthereal/candy tap (not Homebrew/brew or Homebrew/homebrew-core), or even better, submit a PR to fix it:
  /opt/homebrew/Library/Taps/owenthereal/homebrew-candy/Formula/candy.rb:19

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.