Skip to content

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.

License

Notifications You must be signed in to change notification settings

BaseMax/forwarder-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forwarder App

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.

Features

  • 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.

Installation

  1. Clone the repository:

    git clone https://github.com/BaseMax/forwarder-app.git
    cd forwarder-app
  2. Install Go (if you don't have it): Download Go

  3. Run the application:

    go run main.go
  4. Optionally, build the application:

    go build -o forwarder-app.exe

Configuration

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

Configuration Details:

  • 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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright

© 2025 Max Base.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages