Forwarder App is a simple HTTP proxy server written in Go. It forwards requests from different ports to specified target URLs based on predefined routes. This is useful for routing traffic between microservices, load balancing, or general request forwarding.
- Multiple Ports: Supports multiple ports with configurable gateways.
- Custom Routes: Forward requests based on HTTP method and path.
- TLS Support: Configurable TLS settings for secure communication.
- Streaming Support: Handles large responses efficiently with streaming.
- Concurrency: Handles multiple ports and routes concurrently.
-
Clone the repository:
git clone https://github.com/BaseMax/forwarder-app.git cd forwarder-app
-
Install Go (if you don't have it): Download Go
-
Run the application:
go run main.go
-
Optionally, build the application:
go build -o forwarder-app.exe
The application requires a config.json
file to define the ports and routes. Here is an example of the config.json
file:
{
"ports": [
{
"port": 9004,
"gateway": "127.0.0.1:2004",
"routes": [
{ "method": "POST", "path": "/v1/member/register", "target": "127.0.0.1:30031" },
{ "method": "POST", "path": "/v1/login", "target": "127.0.0.1:30031" },
{ "method": "POST", "path": "/v1/verifycode", "target": "127.0.0.1:30031" },
{ "method": "POST", "path": "/v1/getforgetcode", "target": "127.0.0.1:30031" },
{ "method": "POST", "path": "/v1/newpassword", "target": "127.0.0.1:30031" },
{ "method": "POST", "path": "/v1/resendactive", "target": "127.0.0.1:30031" },
{ "method": "POST", "path": "/v1/activeuser", "target": "127.0.0.1:30031" }
]
},
{
"port": 9005,
"gateway": "127.0.0.1:3005",
"routes": []
},
{
"port": 9524,
"gateway": "127.0.0.1:2524",
"routes": []
}
]
}
Run and test:
$ forwarder-app
2025/03/07 18:04:07 Starting server on port 9524
2025/03/07 18:04:07 Starting server on port 9005
2025/03/07 18:04:07 Starting server on port 9004
ports
: List of ports the server will listen on.port
: Port number for the server.gateway
: The address of the target server to forward requests to.routes
: List of routes specifying the HTTP method, path, and target server.
This project is licensed under the MIT License - see the LICENSE file for details.
© 2025 Max Base.