Prox is a simple and easy-to-use forward proxy server on Go.
- HTTP forwarding;
- HTTPS tunneling through CONNECT;
- JSON configuration;
- Pure Go and no external dependencies;
- Requests filtering rules.
git clone https://github.com/r6d0/prox.git
cd ./prox
go run ./cmd/main.go
Prox can be run with the default configuration:
go run ./cmd/main.go
Also, it can be run with user's configuration:
go run ./cmd/main.go ./prox_config.json
JSON configuration is given below:
{
"port": 1080,
"request": {
"timeout": "2s",
"forwardedHeader": false,
"bufferSize": 2048,
"rules": {
"from": "(.*)",
"to": "(.*)"
}
},
"log": {
"level": "ERROR"
}
}| Property | Description |
|---|---|
| port | The server port. It should be from 0 to 65535. The default value is 1080. |
| request.timeout | The request timeout. It has time.Duration syntax. The default value is 2 seconds. |
| request.forwardedHeader | If the value is true, Prox will add the X-Forwarded-For header. The default value is false. |
| request.bufferSize | The buffer size for copying request data. The default value is 2048 bytes (2KB). |
| request.rules.from | The rule for checking the client's address by expressions and blocking the request if necessary. |
| request.rules.to | The rule for checking the target host by expressions and blocking the request if necessary. |
| log.level | The logger level. It should be INFO, ERROR or DEBUG. The default value is ERROR. |
The server port. It should be from 0 to 65535. The default value is 1080.
{
"port": 1080
}The request timeout. It has time.Duration syntax. The default value is 2 seconds.
{
"request": {
"timeout": "2s"
}
}If the value is true, Prox will add the X-Forwarded-For header. The default value is false.
{
"request": {
"forwardedHeader": false
}
}The buffer size for copying request data. The default value is 2048 bytes (2KB).
{
"request": {
"bufferSize": 2048
}
}The rule for checking the client's address by expressions and blocking the request if necessary. By default, all requests will be allowed.
Examples:
Only requests from 127.0.0.1 and 128.0.0.1 will be allowed.
{
"request": {
"rules": {
"from": {
"any": ["127.0.0.1", "128.0.0.1"]
}
}
}
}Only requests from IP addresses that start with 127 will be allowed.
{
"request": {
"rules": {
"from": "(127.*)"
}
}
}Requests from 127.0.0.1 and IP addresses that start with 128 will not be allowed.
{
"request": {
"rules": {
"from": {
"all": ["!127.0.0.1", "!(128.*)"]
}
}
}
}The rule for checking the target host by expressions and blocking the request if necessary. By default, all requests will be allowed.
Examples:
Only requests to mysuper.site or mycool.site will be allowed.
{
"request": {
"rules": {
"to": {
"any": ["mysuper.site", "mycool.site"]
}
}
}
}Only requests to host that starts with my will be allowed.
{
"request": {
"rules": {
"to": "(my.*)"
}
}
}Requests to notsuper.site and notcool.site will not be allowed.
{
"request": {
"rules": {
"to": {
"all": ["!notsuper.site", "!notcool.site"]
}
}
}
}The logger level. It should be INFO, ERROR or DEBUG. The default value is ERROR.
{
"log": {
"level": "ERROR"
}
}