An easy-to-start, YAML-based flexible proxy server for software development. Return customized responses for specific URLs.
- Customizable Responses: Set responses for specific URLs using one of the following methods:
- File: Return any file stored on the storage.
- Rewrite: Rewrite the URL to another URL like a reverse proxy.
- Content: Directly return a string content as the response.
- Transform: Apply a transformation command to the response content.
- Regex Based Matching:
- Use regex to route URLs.
- Dynamically change the reverse proxy destination using variables.
- Default Route Configuration: Choose the behavior when no routing matches.
- Connect to the internet.
- Connect to another proxy.
- Deny access.
You can download the binary files from the GitHub Releases page. Choose the version that suits your operating system and architecture.
If you prefer to build from source, you can install Flexy Proxy using go install.
go install github.com/kajikentaro/flexy-proxy@latest
-
Prepare the executable and add it to your PATH
Make sure theflexybinary is either in your system's PATH or moved to a location like/usr/local/bin. -
Create a
config.yamlfile
Define your routes and responses in aconfig.yamlfile. For example:routes: - url: "http://sample.test" regex: false response: content: "hello world\n"
-
Run the proxy with your config file
Executeflexywith the-fflag pointing to your configuration file:flexy -f config.yaml
-
Use the proxy
Now, you can use the proxy with a tool likecurl:$ curl http://sample.test -x http://localhost:8888 hello world
For more details on configurations, visit: https://kajikentaro.github.io/flexy-proxy/output/
For an example configuration, please refer to examples/basic/config.yaml in the repository.
routes:
# If the request URL is "https://www.google.com", show content from "https://example.com" instead.
- url: "https://www.google.com"
response:
rewrite:
to: "https://example.com"
The following commands create a private key (server.key) and a certificate (server.csr). By specifying options, Flexy Proxy can use this private key and certificate to generate new certificates for the requested hostname and use them for communication. By installing the server.crt certificate on your PC or browser, responses from Flexy Proxy will be considered secure.
openssl genrsa -out server.key
openssl req -x509 -new -nodes -key server.key -sha256 -days 3650 -out server.pem -subj "/C=JP/ST=Tokyo/L=Minato/O=Example Company/OU=IT Department/CN=example.com"
openssl x509 -outform der -in server.pem -out server.crt
Specify the certificates in the YAML file as follows:
certificate: "server.pem"
certificate_key: "server.key"