pull/539/head
arraykeys 1 year ago
parent f7b3a76582
commit de223d666b

@ -269,18 +269,19 @@ By default, the log is displayed directly in the console. If you want to save to
For example: --log proxy.log, the log will be output to the proxy.log to facilitate troubleshooting.
Logging INFO and WARN by default, you can set `--warn` to output warn logging only.
### 5. Generate the certificate file required for encrypted communication
The http, tcp, udp proxy process communicates with the upstream. For security, we use encrypted communication. Of course, we can choose not to encrypt the communication. All the communication and the upstream communication in this tutorial are encrypted, and the certificate file is required.
1. Generate a self-signed certificate and key file with the following command.
`proxy keygen -C proxy`
The certificate file proxy.crt and the key file proxy.key will be generated under the current program directory.
`proxy keygen -C proxy`
The certificate file proxy.crt and the key file proxy.key will be generated under the current program directory.
2. Use the following command to generate a new certificate using the self-signed certificate proxy.crt and the key file proxy.key: goproxy.crt and goproxy.key.
`proxy keygen -s -C proxy -c goproxy`
The certificate file goproxy.crt and the key file goproxy.key will be generated under the current program directory.
`proxy keygen -s -C proxy -c goproxy`
The certificate file goproxy.crt and the key file goproxy.key will be generated under the current program directory.
3. By default, the domain name inside the certificate is random and can be specified using the `-n test.com` parameter.
@ -624,6 +625,8 @@ And the analysis result cache time (--dns-ttl) seconds, to avoid system dns inte
For example:
`proxy http -p ":33080" --dns-address "8.8.8.8:53" --dns-ttl 300`
`--dns-address` supports multiple dns addresses, load balancing, separated by comma. For example: `--dns-address "1.1.1.1:53,8.8.8.8:53"`
### 1.12 Custom encryption
The proxy's http(s) proxy can encrypt tcp data via tls standard encryption and kcp protocol on top of tcp, in addition to support customization after tls and kcp.
Encryption, that is to say, custom encryption and tls|kcp can be used in combination. The internal use of AES256 encryption, you only need to define a password when you use it.
@ -857,12 +860,25 @@ In addition, the `IP` part of the `--bind-ip` parameter supports specifying the
### 2.8 Speed limit, connections limit
The parameter `--max-conns` can limit the maximum number of connections per port.
For example, limit the maximum number of connections per port:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
The parameter `--rate-limit` can limit the rate of each tcp connection.
For example, limit the connection rate of each tcp to 100k/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **Limit count of connections**
The parameter `--max-conns` can limit the maximum number of connections per port.
For example, limit the maximum number of connections per port to 1000:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
- **Limit tcp connection rate**
The parameter `--rate-limit` can limit the rate of each tcp connection.
For example, limit the rate of each tcp connection to 100k/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **Limit client IP total rate**
The parameter `--ip-rate` limit the total rate of each client IP.
For example, limit the total IP rate of each client to 1M/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --ip-rate 1M`
- **Limit port total rate**
The parameter `--port-rate` limit the total rate of each service port.
For example, limit the total rate of each port to 10M/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --port-rate 10M`
- **Joint Speed Limit**
`--rate-limit` and (`--ip-rate` or `--port-rate`) can be used together.
Both limit the total rate and limit the rate of a single tcp.
### 2.9 Compressed transmission
@ -979,7 +995,7 @@ Execute on vps
`proxy server -r ":28080@:80" -P "127.0.0.1:33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -997,11 +1013,11 @@ Configure the domain name wx-dev.xxx.com to the specific directory.
Steps:
1. Execute on vps to ensure that port 80 of vps is not occupied by other programs.
`proxy bridge -p ":33080" -C proxy.crt -K proxy.key`
`proxy server -r ":80@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy bridge -p ":33080" -C proxy.crt -K proxy.key`
`proxy server -r ":80@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
1. Execute on your laptop
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -1019,7 +1035,7 @@ Execute on vps
`proxy server --udp -r ":53@:53" -P "127.0.0.1:33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -1037,10 +1053,10 @@ Execute on vps
`proxy bridge -p ":33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
1. Execute on your home computer
`proxy server -r ":28080@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy server -r ":28080@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -1065,7 +1081,7 @@ Execute on vps
`proxy server -r ":28080@:80" -r ":29090@:21" --k test -P "127.0.0.1:33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client --k test -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client --k test -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -1518,7 +1534,7 @@ such as:
The complete format of `-P` is as follows:
 `protocol://a:b@2.2.2.2:33080#1`
`protocol://a:b@2.2.2.2:33080#1`
Each section is explained below:
@ -1607,10 +1623,10 @@ In this way, when the website is accessed through the local agent 8080, the targ
By default, SPS supports http(s) and socks5 two proxy protocols. We can disable a protocol by parameter.
For example:
1. Disable the HTTP(S) proxy function to retain only the SOCKS5 proxy function, parameter: `--disable-http`.
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-http`
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-http`
1. Disable the SOCKS5 proxy function to retain only the HTTP(S) proxy function, parameter: `--disable-socks`.
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-socks`
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-socks`
### 6.11 Speed limit
@ -1790,16 +1806,16 @@ Dns resolution order:
1. Use the parameter --hosts to parse.
2. If the domain name to be resolved is not found in 1, it is parsed using the parameter --forward rule.
3. The domain name to be resolved is not found in 1 and 2, and the default --default parsing is used. The default default behavior parameter values are three: proxy, direct, and system.
The three parameter values are explained as follows:
Proxy: The domain name is resolved by the dns server specified by the -q parameter.
Direct: Connect to the dns server specified by the -q parameter to resolve the domain name through the local network.
System: resolves the domain name through the system dns.
The three parameter values are explained as follows:
Proxy: The domain name is resolved by the dns server specified by the -q parameter.
Direct: Connect to the dns server specified by the -q parameter to resolve the domain name through the local network.
System: resolves the domain name through the system dns.
Tip:
The host file format specified by the --hosts parameter is the same as the system hosts file, and the domain name supports wildcards. You can refer to the hosts file.
The parsing forwarding rule file specified by the --forward parameter can be referenced to the resolve.rules file. The domain name supports wildcards. It supports multiple dns servers for each domain name to be parsed concurrently. Whoever resolves the fastest resolution will use the resolution result.
The -q parameter can specify multiple remote dns servers to perform concurrent parsing. Whoever resolves the fastest parsing success, the default is: 1.1.1.1, 8.8.8.8, 9.9.9.9, multiple comma-separated,
 For example, you can also bring ports: 1.1.1.1, 8.8.8.8#53, 9.9.9.9
For example, you can also bring ports: 1.1.1.1, 8.8.8.8#53, 9.9.9.9
If you are a standalone service, you don't need a upstream:
Can perform:
@ -1887,6 +1903,7 @@ The proxy's http(s)/socks5/sps proxy function supports user-to-agent access via
- Dynamic upstream, can dynamically obtain its upstream from the API according to the user or client IP, and support http(s)/socks5/ss upstream.
- Authenticate every connection, regardless of whether client authentication is required.
- Cache authentication results, time can be set to reduce API pressure.
- Limit the total bandwidth speed by `user` or `client ip` or `server port`.
#### Specific use
The proxy's http(s)/socks5/sps proxy API function is controlled by three parameters: `--auth-url` and `--auth-nouser` and `--auth-cache`.
@ -1944,6 +1961,9 @@ if($ok){
header("ipqps:2");
header("upstream:http://127.0.0.1:3500?parent-type=tcp");
header("outgoing:1.1.1.1");
header("userTotalRate:1024000");
//header("ipTotalRate:10240");
//header("portTotalRate:10240");
header("HTTP/1.1 204 No Content");
}
```
@ -1957,28 +1977,37 @@ if($ok){
`ipqps`: The maximum number of connections per second (QPS) for the client IP, not limited to 0 or not set this header.
`upstream`: The upstream used, not empty, or not set this header.
`outgoing`: The outgoing ipthis option only working which upstream is empty. And the IP must belong to the machine running proxy。
`userTotalRate` Limit the `user` total bandwidth speed (bytes per second), unit is byte, not limited to 0 or not set this header.
`ipTotalRate`Limit the `client ip` total bandwidth speed (bytes per second), unit is byte, not limited to 0 or not set this header.
`portTotalRate`Limit the `server port` total bandwidth speed (bytes per second), unit is byte, not limited to 0 or not set this header.
#### Details of total bandwidth speed limitation
1. `userrate`、`iprate` and `userTotalRate`、`ipTotalRate`、`portTotalRate` can be set at same time,
for example: set `userrate` with 1024000 to limit the user's total bandwidth speed to 1M/s of user's all tcp connections. And set `userrate` with 102400 to limit the user one tcp connection speed to 100K/s.
2. if `userTotalRate`、`ipTotalRate` 、`portTotalRate` set at same time, the valid order is : `userTotalRate` -> `ipTotalRate` -> `portTotalRate`
3. if `userTotalRate`、`portTotalRate` set at same time, and set `--auth-nouser`all clients that not send username will be as an "empty username" userthey are using a same limiter.
#### Tips
1. By default, `--auth-url` is required to provide the user name and password. If you do not need the client to provide the username and password, and authenticate, you can add `--auth-nouser`. The visit will still access the authentication address `--auth-url` for authentication. Only the $user authentication username and the $pass authentication password received in the php interface are empty when client didn't send username and password.
2. Connection limit priority: User authentication file limit - "File ip.limit limit -" API user limit - "API IP limit -" command line global connection limit.
3. Rate Limit Priority: User Authentication File Rate Limit - "File ip.limit Rate Limit -" API User Rate Limit - "API IP Rate Limit - "Command Line Global Rate Limit.
3. The upstream obtains the priority: the upstream of the user authentication file - the file ip.limit upstream-"API upstream-" command line specifies the upstream.
4.`--auth-cache` authentication cache, cache the authentication result for a certain period of time, improve performance, reduce the pressure on the authentication interface, --auth-cache unit seconds, default 0, set 0 to close the cache.
4.`--auth-cache` authentication cache, cache the authentication result for a certain period of time, improve performance, reduce the pressure on the authentication interface, --auth-cache unit seconds, default 0, set 0 to close the cache.
#### upstream detailed description
1. When the parameter `sps` is 0.
When the service is http, upstream only supports http(s) proxy, and does not support authentication. If authentication is required, it can be replaced by sps. Format:
`http://127.0.0.1:3100?argk=argv`
When the service is a socks, the upstream only supports the socks5 proxy. The format is:
`socks5://127.0.0.1:3100?argk=argv`
When the service is http, upstream only supports http(s) proxy, and does not support authentication. If authentication is required, it can be replaced by sps. Format:
`http://127.0.0.1:3100?argk=argv`
When the service is a socks, the upstream only supports the socks5 proxy. The format is:
`socks5://127.0.0.1:3100?argk=argv`
Explanation: `http://`,`socks5://` is fixed, `127.0.0.1:3100` is the address of the upstream
2. When `sps` is 1.
Upstream supports socks5, http(s) proxy, support authentication, format: `protocol://a:b@2.2.2.2:33080?argk=argv`, please refer to SPS chapter for details, **multiple upstreams** , the description of the `-P` parameter.
Upstream supports socks5, http(s) proxy, support authentication, format: `protocol://a:b@2.2.2.2:33080?argk=argv`, please refer to SPS chapter for details, **multiple upstreams** , the description of the `-P` parameter.
3. Parameters, `?` followed by `argk=argv` are parameters: parameter name = parameter value, multiple parameters are connected with `&`.
All the supported parameters are as follows, and the meaning of the command line with the same name is the same.
All the supported parameters are as follows, and the meaning of the command line with the same name is the same.
1. parent-type : upper-level transport type, support tcp, tls, ws, wss
2. parent-ws-method: The encryption method of the upper-level ws transmission type, the supported value is the same as the value range supported by the command line.
@ -1997,11 +2026,11 @@ The proxy will report the traffic used for this connection to this address.Speci
There are two reporting modes, which can be specified by the `--traffic-mode` parameter. It can be reported in the normal mode or in the fast mode.
1. Report in `normal` normal mode
When the connection is released, the proxy will report the traffic used for this connection to this `--traffic-url` address.
When the connection is released, the proxy will report the traffic used for this connection to this `--traffic-url` address.
2. Report in `fast` mode
For each connection that has been established, the proxy will `timely` report the traffic generated by this connection to this` --traffic-url` address.
`Timing` defaults to 5 seconds, and you can modify` Timing` to the appropriate number of seconds via the parameter `--traffic-interval`.
For each connection that has been established, the proxy will `timely` report the traffic generated by this connection to this` --traffic-url` address.
`Timing` defaults to 5 seconds, and you can modify` Timing` to the appropriate number of seconds via the parameter `--traffic-interval`.
The traffic reporting function combined with the above API authentication function can control the user's traffic usage in real time. The traffic is reported to the interface. The interface writes the traffic data to the database, and then the authentication API queries the database to determine the traffic usage and determine whether the user can be successfully authenticated.
@ -2153,7 +2182,7 @@ agent: is a function parameter, which means running agent mode.
If -i is not specified, the default is empty, and the control panel adds the IP field to fill in: the agent's internet IP.
-u: proxy parameter, empty by default. You can specify an agent, and the agent will communicate with the cluster through this agent.
The format is the same as that of `--jumper`. For details, please refer to the `--jumper` part of the manual.
The format is the same as that of `--jumper`. For details, please refer to the `--jumper` part of the manual.
notice:

@ -308,6 +308,8 @@ http
比如: --log proxy.log日志就会输出到proxy.log方便排除问题。
默认会输出info和warn日志如果只关注warn日志可以使用`--warn`参数只输出warn日志。
### 5. 生成加密通讯需要的证书文件
http(s)代理、tcp代理、udp代理、socks5代理、内网穿透等功能和上级通讯的时候为了安全我们采用TLS加密通讯当然可以选择不加密通信通讯本教程所有和上级通讯都采用加密需要证书文件。
@ -657,6 +659,8 @@ iptables -t nat -A OUTPUT -p tcp -j PROXY
比如:
`proxy http -p ":33080" --dns-address "8.8.8.8:53" --dns-ttl 300`
`--dns-address` 支持设置多个dns地址负载均衡英文半角逗号分割。比如--dns-address "1.1.1.1:53,8.8.8.8:53"
### 1.12 自定义加密
proxy的http(s)代理在tcp之上可以通过tls标准加密以及kcp协议加密tcp数据除此之外还支持在tls和kcp之后进行自定义
@ -927,12 +931,24 @@ port:代理的端口
### 2.8 限速,限制连接数
参数`--max-conns`可以限制每个端口的最大连接数。
比如限制每个端口最多1000个连接数
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
参数`--rate-limit`可以限制每个tcp连接的速率。
比如限制每个tcp连接速率为100k/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **限制连接数**
参数`--max-conns`可以限制每个端口的最大连接数。
比如限制每个端口最多1000个连接数
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
- **限制tcp连接速率**
参数`--rate-limit`可以限制每个tcp连接的速率。
比如限制每个tcp连接速率为100k/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **限制客户端IP总速率**
参数`--ip-rate`可以IP维度限制每个客户端IP的总速率。
比如限制每个客户端IP总速率为1M/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --ip-rate 1M`
- **限制端口总速率**
参数`--port-rate`可以在`服务IP:端口`维度,限制每个服务端口总速率。
比如限制每个端口总速率为10M/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --port-rate 10M`
- **联合限速**
`--rate-limit`和(`--ip-rate`或`--port-rate`可以同时使用。既限制总速率也限制单个tcp速率。
### 2.9 压缩传输
@ -2049,6 +2065,7 @@ proxy的http(s)/socks5/sps代理功能支持通过API控制用户对代理对
- 动态上级可以根据用户或者客户端IP动态的从API获取其上级支持http(s)/socks5/ss上级。
- 认证每一个连接,无论是否要求客户端认证。
- 缓存认证结果时间可以设置减轻API压力。
- 用户维度、客户端IP维度、端口维度的总限速。
#### 具体使用
@ -2109,29 +2126,41 @@ if($ok){
header("ipqps:2");
header("upstream:http://127.0.0.1:3500?parent-type=tcp");
header("outgoing:1.1.1.1");
header("userTotalRate:1024000");
//header("ipTotalRate:10240");
//header("portTotalRate:10240");
header("HTTP/1.1 204 No Content");
}
```
#### HTTP HEADER 头部字段解释
`userconns`用户的最大连接数不限制为0或者不设置这个头部。
`ipconns`IP的最大连接数不限制为0或者不设置这个头部。
`userrate`用户的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
`iprate`IP的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
`userqps`用户每秒可以建立的最大连接数不限制为0或者不设置这个头部。
`ipqps`IP每秒可以建立的最大连接数不限制为0或者不设置这个头部。
`upstream`:使用的上级,没有为空,或者不设置这个头部。
`outgoing`: 使用的出口IP这个设置只有在upstream为空的的时候才有效这里设置的IP必须是proxy所在机器具有的IP。
- `userconns`用户的最大连接数不限制为0或者不设置这个头部。
- `ipconns`IP的最大连接数不限制为0或者不设置这个头部。
- `userrate`用户的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
- `iprate`IP的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
- `userqps`用户每秒可以建立的最大连接数不限制为0或者不设置这个头部。
- `ipqps`IP每秒可以建立的最大连接数不限制为0或者不设置这个头部。
- `upstream`:使用的上级,没有为空,或者不设置这个头部。
- `outgoing`: 使用的出口IP这个设置只有在upstream为空的的时候才有效这里设置的IP必须是proxy所在机器具有的IP。
- `userTotalRate`用户维度限制用户的总带宽速度byte/s单位是字节byte没有留空或者不设置这个头部。
- `ipTotalRate`客户端IP维度限制客户端IP的总带宽速度byte/s单位是字节byte没有留空或者不设置这个头部。
- `portTotalRate`带宽维度限制一个带宽总带宽速度byte/s单位是字节byte没有留空或者不设置这个头部。
#### 限速详细说明
1. 单个tcp限速`userrate`、`iprate`)和总带宽速度(`userTotalRate`、`ipTotalRate`、`portTotalRate`)可以同时设置,
比如设置用户总带宽速度是1M/s`userTotalRate`设置1024000还可以同时设置单个tcp速度是100K/s`userrate`设置102400
2. 如果同时设置了`userTotalRate`、`ipTotalRate` 、`portTotalRate`,有效优先级是:`userTotalRate` -> `ipTotalRate` -> `portTotalRate`
3. 如果同时设置了`userTotalRate`、`portTotalRate`,而且设置了`--auth-nouser`,那么所有没有发用户名的客户端会被认为是`同一个空用户名用户`,共用同一个限制。
#### 提示
1.默认情况下,设置了`--auth-url`是强制要求客户端提供用户名和密码的;如果不需要强制要求客户端提供用户名密码,并认证,可以加上`--auth-nouser`,每次访问仍然会访问认证地址`--auth-url`
进行认证当客户端没有发生认证信息当时候php接口里面接收的$user认证用户名和$pass认证密码都为空。
2.连接数限制优先级:用户认证文件连接数限制-》文件ip.limit连接数限制-》API用户连接数限制-》API的IP连接数限制-》命令行全局连接数限制。
3.速率限制优先级:用户认证文件速率限制-》文件ip.limit速率限制-》API用户速率限制-》API的IP速率限制-》命令行全局速率限制。
3.上级获取优先级用户认证文件的upstream-》文件ip.limit的upstream-》API的upstream-》命令行指定的上级。
4.`--auth-cache`认证缓存,对认证结果缓存一定时间,提升性能,降低认证接口压力,--auth-cache 单位秒默认0, 设置0是关闭缓存。
1. 默认情况下,设置了`--auth-url`是强制要求客户端提供用户名和密码的;如果不需要强制要求客户端提供用户名密码,并认证,可以加上`--auth-nouser`,每次访问仍然会访问认证地址`--auth-url`
进行认证当客户端没有发生认证信息当时候php接口里面接收的$user认证用户名和$pass认证密码都为空。
2. 连接数限制优先级:用户认证文件连接数限制-》文件ip.limit连接数限制-》API用户连接数限制-》API的IP连接数限制-》命令行全局连接数限制。
3. 速率限制优先级:用户认证文件速率限制-》文件ip.limit速率限制-》API用户速率限制-》API的IP速率限制-》命令行全局速率限制。
4. 上级获取优先级用户认证文件的upstream-》文件ip.limit的upstream-》API的upstream-》命令行指定的上级。
5. `--auth-cache`认证缓存,对认证结果缓存一定时间,提升性能,降低认证接口压力,--auth-cache 单位秒默认0, 设置0是关闭缓存。
#### upstream详细说明

@ -62,18 +62,19 @@ By default, the log is displayed directly in the console. If you want to save to
For example: --log proxy.log, the log will be output to the proxy.log to facilitate troubleshooting.
Logging INFO and WARN by default, you can set `--warn` to output warn logging only.
### 5. Generate the certificate file required for encrypted communication
The http, tcp, udp proxy process communicates with the upstream. For security, we use encrypted communication. Of course, we can choose not to encrypt the communication. All the communication and the upstream communication in this tutorial are encrypted, and the certificate file is required.
1. Generate a self-signed certificate and key file with the following command.
`proxy keygen -C proxy`
The certificate file proxy.crt and the key file proxy.key will be generated under the current program directory.
`proxy keygen -C proxy`
The certificate file proxy.crt and the key file proxy.key will be generated under the current program directory.
2. Use the following command to generate a new certificate using the self-signed certificate proxy.crt and the key file proxy.key: goproxy.crt and goproxy.key.
`proxy keygen -s -C proxy -c goproxy`
The certificate file goproxy.crt and the key file goproxy.key will be generated under the current program directory.
`proxy keygen -s -C proxy -c goproxy`
The certificate file goproxy.crt and the key file goproxy.key will be generated under the current program directory.
3. By default, the domain name inside the certificate is random and can be specified using the `-n test.com` parameter.
@ -417,6 +418,8 @@ And the analysis result cache time (--dns-ttl) seconds, to avoid system dns inte
For example:
`proxy http -p ":33080" --dns-address "8.8.8.8:53" --dns-ttl 300`
`--dns-address` supports multiple dns addresses, load balancing, separated by comma. For example: `--dns-address "1.1.1.1:53,8.8.8.8:53"`
### 1.12 Custom encryption
The proxy's http(s) proxy can encrypt tcp data via tls standard encryption and kcp protocol on top of tcp, in addition to support customization after tls and kcp.
Encryption, that is to say, custom encryption and tls|kcp can be used in combination. The internal use of AES256 encryption, you only need to define a password when you use it.
@ -650,12 +653,25 @@ In addition, the `IP` part of the `--bind-ip` parameter supports specifying the
### 2.8 Speed limit, connections limit
The parameter `--max-conns` can limit the maximum number of connections per port.
For example, limit the maximum number of connections per port:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
The parameter `--rate-limit` can limit the rate of each tcp connection.
For example, limit the connection rate of each tcp to 100k/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **Limit count of connections**
The parameter `--max-conns` can limit the maximum number of connections per port.
For example, limit the maximum number of connections per port to 1000:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
- **Limit tcp connection rate**
The parameter `--rate-limit` can limit the rate of each tcp connection.
For example, limit the rate of each tcp connection to 100k/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **Limit client IP total rate**
The parameter `--ip-rate` limit the total rate of each client IP.
For example, limit the total IP rate of each client to 1M/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --ip-rate 1M`
- **Limit port total rate**
The parameter `--port-rate` limit the total rate of each service port.
For example, limit the total rate of each port to 10M/s:
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --port-rate 10M`
- **Joint Speed Limit**
`--rate-limit` and (`--ip-rate` or `--port-rate`) can be used together.
Both limit the total rate and limit the rate of a single tcp.
### 2.9 Compressed transmission
@ -772,7 +788,7 @@ Execute on vps
`proxy server -r ":28080@:80" -P "127.0.0.1:33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -790,11 +806,11 @@ Configure the domain name wx-dev.xxx.com to the specific directory.
Steps:
1. Execute on vps to ensure that port 80 of vps is not occupied by other programs.
`proxy bridge -p ":33080" -C proxy.crt -K proxy.key`
`proxy server -r ":80@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy bridge -p ":33080" -C proxy.crt -K proxy.key`
`proxy server -r ":80@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
1. Execute on your laptop
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -812,7 +828,7 @@ Execute on vps
`proxy server --udp -r ":53@:53" -P "127.0.0.1:33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -830,10 +846,10 @@ Execute on vps
`proxy bridge -p ":33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
1. Execute on your home computer
`proxy server -r ":28080@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy server -r ":28080@:80" -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -858,7 +874,7 @@ Execute on vps
`proxy server -r ":28080@:80" -r ":29090@:21" --k test -P "127.0.0.1:33080" -C proxy.crt -K proxy.key`
1. Execute on company machine A
`proxy client --k test -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
`proxy client --k test -P "22.22.22.22:33080" -C proxy.crt -K proxy.key`
Complete
@ -1311,7 +1327,7 @@ such as:
The complete format of `-P` is as follows:
 `protocol://a:b@2.2.2.2:33080#1`
`protocol://a:b@2.2.2.2:33080#1`
Each section is explained below:
@ -1400,10 +1416,10 @@ In this way, when the website is accessed through the local agent 8080, the targ
By default, SPS supports http(s) and socks5 two proxy protocols. We can disable a protocol by parameter.
For example:
1. Disable the HTTP(S) proxy function to retain only the SOCKS5 proxy function, parameter: `--disable-http`.
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-http`
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-http`
1. Disable the SOCKS5 proxy function to retain only the HTTP(S) proxy function, parameter: `--disable-socks`.
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-socks`
`proxy sps -T tcp -P 3.3.3.3:8888 -M -t tcp -p :8080 --disable-socks`
### 6.11 Speed limit
@ -1583,16 +1599,16 @@ Dns resolution order:
1. Use the parameter --hosts to parse.
2. If the domain name to be resolved is not found in 1, it is parsed using the parameter --forward rule.
3. The domain name to be resolved is not found in 1 and 2, and the default --default parsing is used. The default default behavior parameter values are three: proxy, direct, and system.
The three parameter values are explained as follows:
Proxy: The domain name is resolved by the dns server specified by the -q parameter.
Direct: Connect to the dns server specified by the -q parameter to resolve the domain name through the local network.
System: resolves the domain name through the system dns.
The three parameter values are explained as follows:
Proxy: The domain name is resolved by the dns server specified by the -q parameter.
Direct: Connect to the dns server specified by the -q parameter to resolve the domain name through the local network.
System: resolves the domain name through the system dns.
Tip:
The host file format specified by the --hosts parameter is the same as the system hosts file, and the domain name supports wildcards. You can refer to the hosts file.
The parsing forwarding rule file specified by the --forward parameter can be referenced to the resolve.rules file. The domain name supports wildcards. It supports multiple dns servers for each domain name to be parsed concurrently. Whoever resolves the fastest resolution will use the resolution result.
The -q parameter can specify multiple remote dns servers to perform concurrent parsing. Whoever resolves the fastest parsing success, the default is: 1.1.1.1, 8.8.8.8, 9.9.9.9, multiple comma-separated,
 For example, you can also bring ports: 1.1.1.1, 8.8.8.8#53, 9.9.9.9
For example, you can also bring ports: 1.1.1.1, 8.8.8.8#53, 9.9.9.9
If you are a standalone service, you don't need a upstream:
Can perform:
@ -1680,6 +1696,7 @@ The proxy's http(s)/socks5/sps proxy function supports user-to-agent access via
- Dynamic upstream, can dynamically obtain its upstream from the API according to the user or client IP, and support http(s)/socks5/ss upstream.
- Authenticate every connection, regardless of whether client authentication is required.
- Cache authentication results, time can be set to reduce API pressure.
- Limit the total bandwidth speed by `user` or `client ip` or `server port`.
#### Specific use
The proxy's http(s)/socks5/sps proxy API function is controlled by three parameters: `--auth-url` and `--auth-nouser` and `--auth-cache`.
@ -1737,6 +1754,9 @@ if($ok){
header("ipqps:2");
header("upstream:http://127.0.0.1:3500?parent-type=tcp");
header("outgoing:1.1.1.1");
header("userTotalRate:1024000");
//header("ipTotalRate:10240");
//header("portTotalRate:10240");
header("HTTP/1.1 204 No Content");
}
```
@ -1750,28 +1770,37 @@ if($ok){
`ipqps`: The maximum number of connections per second (QPS) for the client IP, not limited to 0 or not set this header.
`upstream`: The upstream used, not empty, or not set this header.
`outgoing`: The outgoing ipthis option only working which upstream is empty. And the IP must belong to the machine running proxy。
`userTotalRate` Limit the `user` total bandwidth speed (bytes per second), unit is byte, not limited to 0 or not set this header.
`ipTotalRate`Limit the `client ip` total bandwidth speed (bytes per second), unit is byte, not limited to 0 or not set this header.
`portTotalRate`Limit the `server port` total bandwidth speed (bytes per second), unit is byte, not limited to 0 or not set this header.
#### Details of total bandwidth speed limitation
1. `userrate`、`iprate` and `userTotalRate`、`ipTotalRate`、`portTotalRate` can be set at same time,
for example: set `userrate` with 1024000 to limit the user's total bandwidth speed to 1M/s of user's all tcp connections. And set `userrate` with 102400 to limit the user one tcp connection speed to 100K/s.
2. if `userTotalRate`、`ipTotalRate` 、`portTotalRate` set at same time, the valid order is : `userTotalRate` -> `ipTotalRate` -> `portTotalRate`
3. if `userTotalRate`、`portTotalRate` set at same time, and set `--auth-nouser`all clients that not send username will be as an "empty username" userthey are using a same limiter.
#### Tips
1. By default, `--auth-url` is required to provide the user name and password. If you do not need the client to provide the username and password, and authenticate, you can add `--auth-nouser`. The visit will still access the authentication address `--auth-url` for authentication. Only the $user authentication username and the $pass authentication password received in the php interface are empty when client didn't send username and password.
2. Connection limit priority: User authentication file limit - "File ip.limit limit -" API user limit - "API IP limit -" command line global connection limit.
3. Rate Limit Priority: User Authentication File Rate Limit - "File ip.limit Rate Limit -" API User Rate Limit - "API IP Rate Limit - "Command Line Global Rate Limit.
3. The upstream obtains the priority: the upstream of the user authentication file - the file ip.limit upstream-"API upstream-" command line specifies the upstream.
4.`--auth-cache` authentication cache, cache the authentication result for a certain period of time, improve performance, reduce the pressure on the authentication interface, --auth-cache unit seconds, default 0, set 0 to close the cache.
4.`--auth-cache` authentication cache, cache the authentication result for a certain period of time, improve performance, reduce the pressure on the authentication interface, --auth-cache unit seconds, default 0, set 0 to close the cache.
#### upstream detailed description
1. When the parameter `sps` is 0.
When the service is http, upstream only supports http(s) proxy, and does not support authentication. If authentication is required, it can be replaced by sps. Format:
`http://127.0.0.1:3100?argk=argv`
When the service is a socks, the upstream only supports the socks5 proxy. The format is:
`socks5://127.0.0.1:3100?argk=argv`
When the service is http, upstream only supports http(s) proxy, and does not support authentication. If authentication is required, it can be replaced by sps. Format:
`http://127.0.0.1:3100?argk=argv`
When the service is a socks, the upstream only supports the socks5 proxy. The format is:
`socks5://127.0.0.1:3100?argk=argv`
Explanation: `http://`,`socks5://` is fixed, `127.0.0.1:3100` is the address of the upstream
2. When `sps` is 1.
Upstream supports socks5, http(s) proxy, support authentication, format: `protocol://a:b@2.2.2.2:33080?argk=argv`, please refer to SPS chapter for details, **multiple upstreams** , the description of the `-P` parameter.
Upstream supports socks5, http(s) proxy, support authentication, format: `protocol://a:b@2.2.2.2:33080?argk=argv`, please refer to SPS chapter for details, **multiple upstreams** , the description of the `-P` parameter.
3. Parameters, `?` followed by `argk=argv` are parameters: parameter name = parameter value, multiple parameters are connected with `&`.
All the supported parameters are as follows, and the meaning of the command line with the same name is the same.
All the supported parameters are as follows, and the meaning of the command line with the same name is the same.
1. parent-type : upper-level transport type, support tcp, tls, ws, wss
2. parent-ws-method: The encryption method of the upper-level ws transmission type, the supported value is the same as the value range supported by the command line.
@ -1790,11 +1819,11 @@ The proxy will report the traffic used for this connection to this address.Speci
There are two reporting modes, which can be specified by the `--traffic-mode` parameter. It can be reported in the normal mode or in the fast mode.
1. Report in `normal` normal mode
When the connection is released, the proxy will report the traffic used for this connection to this `--traffic-url` address.
When the connection is released, the proxy will report the traffic used for this connection to this `--traffic-url` address.
2. Report in `fast` mode
For each connection that has been established, the proxy will `timely` report the traffic generated by this connection to this` --traffic-url` address.
`Timing` defaults to 5 seconds, and you can modify` Timing` to the appropriate number of seconds via the parameter `--traffic-interval`.
For each connection that has been established, the proxy will `timely` report the traffic generated by this connection to this` --traffic-url` address.
`Timing` defaults to 5 seconds, and you can modify` Timing` to the appropriate number of seconds via the parameter `--traffic-interval`.
The traffic reporting function combined with the above API authentication function can control the user's traffic usage in real time. The traffic is reported to the interface. The interface writes the traffic data to the database, and then the authentication API queries the database to determine the traffic usage and determine whether the user can be successfully authenticated.
@ -1946,7 +1975,7 @@ agent: is a function parameter, which means running agent mode.
If -i is not specified, the default is empty, and the control panel adds the IP field to fill in: the agent's internet IP.
-u: proxy parameter, empty by default. You can specify an agent, and the agent will communicate with the cluster through this agent.
The format is the same as that of `--jumper`. For details, please refer to the `--jumper` part of the manual.
The format is the same as that of `--jumper`. For details, please refer to the `--jumper` part of the manual.
notice:

@ -87,6 +87,8 @@ http
比如: --log proxy.log日志就会输出到proxy.log方便排除问题。
默认会输出info和warn日志如果只关注warn日志可以使用`--warn`参数只输出warn日志。
### 5. 生成加密通讯需要的证书文件
http(s)代理、tcp代理、udp代理、socks5代理、内网穿透等功能和上级通讯的时候为了安全我们采用TLS加密通讯当然可以选择不加密通信通讯本教程所有和上级通讯都采用加密需要证书文件。
@ -436,6 +438,8 @@ iptables -t nat -A OUTPUT -p tcp -j PROXY
比如:
`proxy http -p ":33080" --dns-address "8.8.8.8:53" --dns-ttl 300`
`--dns-address` 支持设置多个dns地址负载均衡英文半角逗号分割。比如--dns-address "1.1.1.1:53,8.8.8.8:53"
### 1.12 自定义加密
proxy的http(s)代理在tcp之上可以通过tls标准加密以及kcp协议加密tcp数据除此之外还支持在tls和kcp之后进行自定义
@ -706,12 +710,24 @@ port:代理的端口
### 2.8 限速,限制连接数
参数`--max-conns`可以限制每个端口的最大连接数。
比如限制每个端口最多1000个连接数
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
参数`--rate-limit`可以限制每个tcp连接的速率。
比如限制每个tcp连接速率为100k/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **限制连接数**
参数`--max-conns`可以限制每个端口的最大连接数。
比如限制每个端口最多1000个连接数
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --max-conns 1000`
- **限制tcp连接速率**
参数`--rate-limit`可以限制每个tcp连接的速率。
比如限制每个tcp连接速率为100k/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --rate-limit 100k`
- **限制客户端IP总速率**
参数`--ip-rate`可以IP维度限制每个客户端IP的总速率。
比如限制每个客户端IP总速率为1M/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --ip-rate 1M`
- **限制端口总速率**
参数`--port-rate`可以在`服务IP:端口`维度,限制每个服务端口总速率。
比如限制每个端口总速率为10M/s
`proxy tcp -p ":33080" -T tcp -P "192.168.22.33:22" --port-rate 10M`
- **联合限速**
`--rate-limit`和(`--ip-rate`或`--port-rate`可以同时使用。既限制总速率也限制单个tcp速率。
### 2.9 压缩传输
@ -1828,6 +1844,7 @@ proxy的http(s)/socks5/sps代理功能支持通过API控制用户对代理对
- 动态上级可以根据用户或者客户端IP动态的从API获取其上级支持http(s)/socks5/ss上级。
- 认证每一个连接,无论是否要求客户端认证。
- 缓存认证结果时间可以设置减轻API压力。
- 用户维度、客户端IP维度、端口维度的总限速。
#### 具体使用
@ -1888,29 +1905,41 @@ if($ok){
header("ipqps:2");
header("upstream:http://127.0.0.1:3500?parent-type=tcp");
header("outgoing:1.1.1.1");
header("userTotalRate:1024000");
//header("ipTotalRate:10240");
//header("portTotalRate:10240");
header("HTTP/1.1 204 No Content");
}
```
#### HTTP HEADER 头部字段解释
`userconns`用户的最大连接数不限制为0或者不设置这个头部。
`ipconns`IP的最大连接数不限制为0或者不设置这个头部。
`userrate`用户的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
`iprate`IP的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
`userqps`用户每秒可以建立的最大连接数不限制为0或者不设置这个头部。
`ipqps`IP每秒可以建立的最大连接数不限制为0或者不设置这个头部。
`upstream`:使用的上级,没有为空,或者不设置这个头部。
`outgoing`: 使用的出口IP这个设置只有在upstream为空的的时候才有效这里设置的IP必须是proxy所在机器具有的IP。
- `userconns`用户的最大连接数不限制为0或者不设置这个头部。
- `ipconns`IP的最大连接数不限制为0或者不设置这个头部。
- `userrate`用户的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
- `iprate`IP的单个TCP连接速率限制单位字节/秒不限制为0或者不设置这个头部。
- `userqps`用户每秒可以建立的最大连接数不限制为0或者不设置这个头部。
- `ipqps`IP每秒可以建立的最大连接数不限制为0或者不设置这个头部。
- `upstream`:使用的上级,没有为空,或者不设置这个头部。
- `outgoing`: 使用的出口IP这个设置只有在upstream为空的的时候才有效这里设置的IP必须是proxy所在机器具有的IP。
- `userTotalRate`用户维度限制用户的总带宽速度byte/s单位是字节byte没有留空或者不设置这个头部。
- `ipTotalRate`客户端IP维度限制客户端IP的总带宽速度byte/s单位是字节byte没有留空或者不设置这个头部。
- `portTotalRate`带宽维度限制一个带宽总带宽速度byte/s单位是字节byte没有留空或者不设置这个头部。
#### 限速详细说明
1. 单个tcp限速`userrate`、`iprate`)和总带宽速度(`userTotalRate`、`ipTotalRate`、`portTotalRate`)可以同时设置,
比如设置用户总带宽速度是1M/s`userTotalRate`设置1024000还可以同时设置单个tcp速度是100K/s`userrate`设置102400
2. 如果同时设置了`userTotalRate`、`ipTotalRate` 、`portTotalRate`,有效优先级是:`userTotalRate` -> `ipTotalRate` -> `portTotalRate`
3. 如果同时设置了`userTotalRate`、`portTotalRate`,而且设置了`--auth-nouser`,那么所有没有发用户名的客户端会被认为是`同一个空用户名用户`,共用同一个限制。
#### 提示
1.默认情况下,设置了`--auth-url`是强制要求客户端提供用户名和密码的;如果不需要强制要求客户端提供用户名密码,并认证,可以加上`--auth-nouser`,每次访问仍然会访问认证地址`--auth-url`
进行认证当客户端没有发生认证信息当时候php接口里面接收的$user认证用户名和$pass认证密码都为空。
2.连接数限制优先级:用户认证文件连接数限制-》文件ip.limit连接数限制-》API用户连接数限制-》API的IP连接数限制-》命令行全局连接数限制。
3.速率限制优先级:用户认证文件速率限制-》文件ip.limit速率限制-》API用户速率限制-》API的IP速率限制-》命令行全局速率限制。
3.上级获取优先级用户认证文件的upstream-》文件ip.limit的upstream-》API的upstream-》命令行指定的上级。
4.`--auth-cache`认证缓存,对认证结果缓存一定时间,提升性能,降低认证接口压力,--auth-cache 单位秒默认0, 设置0是关闭缓存。
1. 默认情况下,设置了`--auth-url`是强制要求客户端提供用户名和密码的;如果不需要强制要求客户端提供用户名密码,并认证,可以加上`--auth-nouser`,每次访问仍然会访问认证地址`--auth-url`
进行认证当客户端没有发生认证信息当时候php接口里面接收的$user认证用户名和$pass认证密码都为空。
2. 连接数限制优先级:用户认证文件连接数限制-》文件ip.limit连接数限制-》API用户连接数限制-》API的IP连接数限制-》命令行全局连接数限制。
3. 速率限制优先级:用户认证文件速率限制-》文件ip.limit速率限制-》API用户速率限制-》API的IP速率限制-》命令行全局速率限制。
4. 上级获取优先级用户认证文件的upstream-》文件ip.limit的upstream-》API的upstream-》命令行指定的上级。
5. `--auth-cache`认证缓存,对认证结果缓存一定时间,提升性能,降低认证接口压力,--auth-cache 单位秒默认0, 设置0是关闭缓存。
#### upstream详细说明

Loading…
Cancel
Save