Proxy outgoing requests to alternate servers with fine-grained control
Install using cargo
$ git clone https://github.com/sanket143/proxyl
$ cd proxyl
$ cargo install --path . --locked
This will create a certificate and key with expiry of 30 days
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 30 -subj "/C=ZZ/ST=ZZ/L=ZZ/O=Proxyl/CN=Proxyl"
$ proxyl add-certificate --cert-path ./cert.pem --key-path ./key.pem
Add `~/.config/proxyl/config.toml` to fine-grain the proxy server
Example:
# Rules are the fundamental part of the configuration
# If the request matches any of the defined rule, it'll redirect the request to the said url
[rules.example-sanket143]
uri = "https://example.com:443/api"
method = "POST"
redirect_to = "http://localhost:3000/api"
headers = { "origin" = "https://example.com" }
body_re = "username=sanket143" # regex that will be applied with the content of the request body
enabled = false # whether the rule is active or not, by default the value is `true`
If there happened to be multiple rules with similar attributes, it can become repetitive. In that case, we can define config and extend those in the rules
[config.example]
uri = "https://example.com:443/api"
method = "POST"
redirect_to = "http://localhost:3000/api"
headers = { "origin" = "https://example.com" }
[rules.example-sanket143]
config = "example"
body_re = "username=sanket143"
[rules.example-octacat]
config = "example"
body_re = "username=octacat"
enabled = false
- Make sure you mention port number in the uri. NOTE 443 in
https://example.com:443/api