@@ -22,8 +22,6 @@ AHP使用了部分C++17特性,所以对编译器的版本有较高要求,下
2222 - GCC >= 7.3
2323 - Clang >= 6.0
2424
25- 如果你想要使用低版本的编译器(C++11)来编译,可以试试[ 这个分支] ( https://github.com/lxrite/azure-http-proxy/tree/cpp11 ) 。
26-
2725### 安装依赖
2826
2927 - OpenSSL
@@ -34,31 +32,38 @@ AHP使用了部分C++17特性,所以对编译器的版本有较高要求,下
3432
3533##### Ubuntu
3634
37- $ apt-get install libssl-dev
35+ ``` shell
36+ $ apt-get install libssl-dev
37+ ```
3838
39- ##### Fedora
39+ ##### CentOS
4040
41- $ yum install openssl
42- $ yum install openssl-devel
41+ ``` shell
42+ $ yum install openssl
43+ $ yum install openssl-devel
44+ ```
4345
4446#### Windows
4547
4648Windows可以使用[ vcpkg] ( https://github.com/Microsoft/vcpkg ) 来安装OpenSSL。
4749
48- $ vcpkg install openssl
50+ ``` shell
51+ $ vcpkg install openssl
52+ ```
4953
5054### 编译
5155AHP使用自动化构建工具CMake来实现跨平台构建
5256
5357 - CMake >= 2.8
5458
5559Windows下可以使用cmake-gui.exe,Linux或其他类Unix系统可以使用下面的命令编译
56-
57- $ cd azure-http-proxy
58- $ mkdir build
59- $ cd build
60- $ cmake -DCMAKE_BUILD_TYPE=Release ..
61- $ cmake --build .
60+ ``` shell
61+ $ cd azure-http-proxy
62+ $ mkdir build
63+ $ cd build
64+ $ cmake -DCMAKE_BUILD_TYPE=Release ..
65+ $ cmake --build .
66+ ```
6267
6368如果编译成功会生成ahpc(客户端)和ahps(服务端)。
6469
@@ -71,34 +76,36 @@ OpenWrt/LEDE 编译参考 [openwrt-ahp](https://github.com/lxrite/openwrt-ahp)
7176注意:不要使用示例配置中的RSA私钥和公钥,因为私钥一公开就是不安全的了。
7277
7378如果你要运行的是服务端,那么你首先需要生成一对RSA密钥对,AHP支持任意长度不小于1024位的RSA密钥。下面的命令使用openssl生成2048位的私钥和公钥
74-
75- $ openssl genrsa -out rsa_private_key.pem 2048
76- $ openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
79+ ``` shell
80+ $ openssl genrsa -out rsa_private_key.pem 2048
81+ $ openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
82+ ```
7783
7884服务端保留私钥并将公钥告诉客户端。
7985
8086### 配置服务端
8187
82- 编辑server.json文件,Windows下应将此文件放到ahps.exe同目录下,Linux或其他类Unix系统将此文件放到~ /.ahps/server.json。
83-
88+ 编辑` server.json ` 文件
89+ ``` json
90+ {
91+ "bind_address" : " 0.0.0.0" ,
92+ "listen_port" : 8090 ,
93+ "rsa_private_key" : " -----BEGIN RSA PRIVATE KEY----- ...... -----END RSA PRIVATE KEY-----" ,
94+ "timeout" : 240 ,
95+ "workers" : 4 ,
96+ "auth" : true ,
97+ "users" : [
8498 {
85- "bind_address": "0.0.0.0",
86- "listen_port": 8090,
87- "rsa_private_key": "-----BEGIN RSA PRIVATE KEY----- ...... -----END RSA PRIVATE KEY-----",
88- "timeout": 240,
89- "workers": 4,
90- "auth": true,
91- "users": [
92- {
93- "username": "username1",
94- "password": "password1"
95- },
96- {
97- "username": "foobar",
98- "password": "bazqux"
99- }
100- ]
99+ "username" : " username1" ,
100+ "password" : " password1"
101+ },
102+ {
103+ "username" : " foobar" ,
104+ "password" : " bazqux"
101105 }
106+ ]
107+ }
108+ ```
102109
103110字段名 | 描述 | 是否必选 | 默认值 |
104111----------------|--------------------|------------------|-----------|
@@ -112,18 +119,19 @@ users | 用户列表 | auth为true时必选 | 无 |
112119
113120### 配置客户端
114121
115- 编辑client.json文件,Windows下应将此文件放到ahpc.exe或ahpc-gui.exe同目录下,Linux或其他类Unix系统将此文件放到~ /.ahpc/client.json。
116-
117- {
118- "proxy_server_address": "127.0.0.1",
119- "proxy_server_port": 8090,
120- "bind_address": "127.0.0.1",
121- "listen_port": 8089,
122- "rsa_public_key": "-----BEGIN PUBLIC KEY----- ...... -----END PUBLIC KEY-----",
123- "cipher": "aes-256-cfb",
124- "timeout": 240,
125- "workers": 2
126- }
122+ 编辑` client.json ` 文件
123+ ``` json
124+ {
125+ "proxy_server_address" : " 127.0.0.1" ,
126+ "proxy_server_port" : 8090 ,
127+ "bind_address" : " 127.0.0.1" ,
128+ "listen_port" : 8089 ,
129+ "rsa_public_key" : " -----BEGIN PUBLIC KEY----- ...... -----END PUBLIC KEY-----" ,
130+ "cipher" : " aes-256-cfb" ,
131+ "timeout" : 240 ,
132+ "workers" : 2
133+ }
134+ ```
127135
128136字段名 | 描述 | 是否必选 | 默认值 |
129137---------------------|----------------------|------------------|---------------|
@@ -152,31 +160,35 @@ workers | 并发工作线程数 | 否 | 2
152160
153161### 运行服务端
154162
155- Linux或其他类Unix系统
156-
157- $ ./ahps
158-
159- Windows
160-
161- $ ahps.exe
162-
163+ Linux或其他类Unix系统
164+ ``` shell
165+ $ ./ahps -c server.json
166+ ```
167+
168+ Windows
169+ ``` shell
170+ $ ahps.exe -c server.json
171+ ```
172+
163173### 运行客户端
164174
165175Linux或其他类Unix系统
166-
167- $ ./ahpc
176+ ``` shell
177+ $ ./ahpc -c client.json
178+ ```
168179
169180Windows
170-
171- $ ahpc.exe
181+ ``` shell
182+ $ ahpc.exe -c client.json
183+ ```
172184
173185## 使用Docker
174- ``` bash
186+ ``` shell
175187# 使用拉取到本地的源码进行构建
176188docker build . -t lxrite/azure-http-proxy
177189# 或者使用URL自动拉取源码构建
178190docker build -t lxrite/azure-http-proxy https://github.com/lxrite/azure-http-proxy.git
179191
180192# 启动 ahps
181- docker run -d -p 8090:8090 --mount type=bind,source=$PWD /server.json,target=/root/.ahps /server.json lxrite/azure-http-proxy ahps
193+ docker run -d -p 8090:8090 --mount type=bind,source=$PWD /server.json,target=/data/ahp /server.json lxrite/azure-http-proxy ahps -c /data/ahp/server.json
182194```
0 commit comments