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.
- 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.
The basic command format is as follows:
go-http-agent --port <port number> --context-path <context path> --proxy-url <target proxy URL>
-
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:
-
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
This configuration allows you to proxy HTTPS requests, such as proxying to Google.
-
** Websocket Proxy**:
go-http-agent --port 8090 --context-path /xxx --proxy-url ws://www.baidu.com/yyy
--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).