Lightweight local proxy, useful for giving your local services memorable local domain names like myproject.wip instead of localhost:8000.
Key features!
- Super simple proxy-based setup
- Choose your own local tld, e.g.
.localhostor.wip - Wildcard subdomains, e.g.
*.devserver.wip - Zero config HTTPS support for all mapped URLs
- Proxy mode: route requests to a local server
- File server mode: serve files directly from a folder
brew install octavore/tools/lightproxy
To have homebrew start lightproxy when you start your computer
brew services start octavore/tools/lightproxy
To map foo.wip to localhost:3000:
lightproxy set-dest foo.wip 3000To map foo.wip to a folder:
lightproxy set-dir foo.wip ~/Code/foo/Open up a new terminal shell and run lightproxy.
- Go to System Preferences > Network > Proxies.
- Select and check Automatic Proxy Configuration in the sidebar.
- Set the URL to http://localhost:7999/proxy.pac
All proxied URLS are also automatically available over https, i.e. http://foo.wip is also served with https at https://foo.wip.
Internally, lightproxy does this by listening for TLS connections on a separate port, 7998. You can change this port if it conflicts with another app you have running. You should never need to connect to it directly.
Please note that you will see browser warnings because lightproxy generates a self-signed certificate. To suppress the warnings, you can tell lightproxy to sign certificates using a locally trusted root CA. There are two ways to do this: using mkcert, or generating your own local CA using openssl.
- Install
mkcertwithbrew install mkcert - Run
mkcert -installto generate and install its root CA - Set
mkcerttotrueinconfig.json.
-
Generate a local CA key file
openssl genrsa -out lightproxyCA.key 4096 openssl req -x509 -new -nodes -key lightproxyCA.key -sha256 -days 1024 -out lightproxyCA.crt -
Trust the key file
If you are on a Mac, open Keychain Access in System Preference, select the System keychain, select the Certificates category, and drag your key file into the list of certificates.
Double click the certificate, open up the Trust section, and make sure When using this certificate: is set to Always Trust. Restart your browsers for this to take effect.
-
Set
ca_key_filein lightproxy's configTell lightproxy where to find your files by setting the
ca_key_fileparameter inconfig.json(see below). Set it to the keyfile path you generated in step 1. Restart lightproxy.
URL mappings can be added easily using the commands above, but you can also edit the config file directly.
To view the current config and where it is saved, run this:
lightproxy config
Example config
lightproxy uses a proxy auto-config file to tell your system what URLs to send to the proxy.
By default, this PAC file is served at http://localhost:7999/proxy.pac. It contains a simple javascript function:
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*.wip")) {
return "PROXY 127.0.0.1:7999";
}
return "DIRECT";
}Resources
- Secure websockets do not proxy correctly in Safari.
- Fixed support for secure websockets (credit: @jonian)
- Add support for
mkcertin config. - Add support for explicitly defining CA cert file in config:
ca_cert_file.
- Search both
$XDG_CONFIG_HOMEand$HOME/.config/lightproxy forconfig.json(preferring the former if set). This change improves thebrew installation` experience while maintaining backward compatability.
- Support wildcards in source url
- Added TLS support
- Added
tls_addrandca_key_fileconfig option

{ # only hosts ending in this tld are handled by the proxy "tld": "wip", # the local addr the proxy listens on "addr": "localhost:7999", # the local addr the proxy listens on internally to handle # TLSrequests "tls_addr": "localhost:7998", # if you are using mkcert for your local CA, this should be set to true "mkcert": false, # if you are using a local CA, this should be set to the value # of the *.key file. The corresponding *.crt should be in the same # folder. "ca_key_file": "...", # if you are using a local CA, this should be set to the value # of the certificate file, if it cannot be inferred from the ca_key_file value. "ca_cert_file": "...", # all hosts to map. Entries must have `host` set, and # either `dest` (a local addr), or `dest_folder` (a folder) "entries": [ { "host": "ketchup.wip", "dest": "localhost:8000" }, { "host": "goatcodes.wip", "dest": "localhost:8100" }, { "host": "go.goatcodes.wip", "dest": "localhost:8100" }, { "host": "blog.goatcodes.wip", "dest_folder": "/sites/goatblog" } ] }