Lightweight proxy, useful for giving your local services memorable local domain names like myproject.wip
instead of localhost:8000
. TLS is also supported
brew install octavore/tools/lightproxy
To map foo.wip
to localhost:3000
:
lightproxy set-dest foo.wip 3000
To 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 available over https. Lightproxy does this by listening for TLS connections on a separate port (configurable).
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.
-
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_file
in lightproxy's configTell lightproxy where to find your files by setting the
ca_key_file
parameter 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
- added TLS support
- added
tls_addr
andca_key_file
config option