Total Pageviews

Saturday, 15 June 2024

go-http-agent

 使用go语言编写的http代理程序。

go-http-agent is an HTTP proxy program written in Go language. It supports reverse proxy functionality, allowing the forwarding of client HTTP requests to a specified server and then returning the server response to the client, along with the capability to save static files locally. This proxy program supports both HTTP and HTTPS protocols and is suitable for a variety of network environments and requirements.

Features

  • Reverse Proxy: Capable of forwarding client requests to any HTTP/HTTPS server.
  • Flexible Configuration: Customize the port, context path, and target proxy URL via command-line arguments.
  • HTTPS Support: Able to handle HTTPS requests, making it suitable for security-sensitive application scenarios.
  • Static File Saving: Supports saving accessed static files to a specified local directory.

Start Commands

The basic command format is as follows:

go-http-agent --port <port number> --context-path <context path> --proxy-url <target proxy URL>

Examples

  • Reverse Proxy to Baidu:

    go-http-agent --port 8080 --context-path / --proxy-url http://www.baidu.com
  • Once successfully set, the reverse proxy to Baidu appears as shown in the following image: Reverse Proxy Baidu Example

  • Custom Project Name:

    go-http-agent --port 8080 --context-path /xxx --proxy-url http://www.baidu.com/yyy
  • With this configuration, you can access the proxy target through a custom context path.

  • HTTPS Proxy:

    go-http-agent --port 8080 --context-path / --proxy-url https://www.google.com
    1. This configuration allows you to proxy HTTPS requests, such as proxying to Google.

    2. ** Websocket Proxy**:

    go-http-agent --port 8090 --context-path /xxx --proxy-url ws://www.baidu.com/yyy

    Parameter Explanation

    • --port: Sets the listening port for the proxy server.
    • --context-path: Defines the context path of the proxy server.
    • --proxy-url: Specifies the target URL to which requests will be proxied.
    • --save-dir: Specifies the path for saving static files (used for saving static resources accessed during browsing).
    from https://github.com/litongjava/go-http-agent

    No comments:

    Post a Comment