BPROXY เป็นพร็อกซีเซิร์ฟเวอร์ที่มีน้ำหนักเบา มากที่สุดที่ มีน้ำหนัก เบา ที่สุดที่เขียนใน C.
รองรับการบีบอัด
gzip
และSSL
นอกกรอบ
เราทดสอบแอพ whoami ง่าย ๆ บนเว็บเซิร์ฟเวอร์ Golang โดยใช้ WRK การทดสอบได้ดำเนินการใน MacBook Pro ปลายปี 2559 ด้วยหน่วยความจำ 16GB โดยใช้คำสั่งต่อไปนี้:
nginx
$ wrk -t20 -c1000 -d10s http://whoami.home.local.net
Running 10s test @ http://whoami.home.local.net
20 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 95.03ms 55.24ms 594.79ms 85.69%
Req/Sec 78.38 47.01 230.00 65.43%
7786 requests in 10.06s, 2.85MB read
Socket errors: connect 0, read 872, write 0, timeout 92
Non-2xx or 3xx responses: 52
Requests/sec: 774.08
Transfer/sec: 290.10KB
bproxy
$ wrk -t20 -c1000 -d10s http://whoami.home.local.net
Running 10s test @ http://whoami.home.local.net
20 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 274.84ms 117.52ms 1.05s 71.95%
Req/Sec 97.55 55.21 515.00 71.70%
19292 requests in 10.10s, 6.66MB read
Socket errors: connect 0, read 970, write 0, timeout 0
Requests/sec: 1910.05
Transfer/sec: 675.23KB
ผลการวิจัยชี้ให้เห็นว่า nginx
จัดการคำขอที่มีเวลาแฝงน้อยกว่า 50% ในขณะที่ bproxy
จัดการคำขอมากกว่าสองเท่าในช่วงเวลาเดียวกัน
เมื่อฟังดูมีแนวโน้มอย่าลังเลที่จะใช้มันบนเซิร์ฟเวอร์ของคุณและช่วยเราปรับปรุงโครงการนี้ต่อไป!
ขั้นตอนนี้จะถือว่าคุณติดตั้ง node.js ในระบบของคุณ
ติดตั้งการพึ่งพา
$ npm install --prod
เรียกใช้งานสร้าง
$ npm run build
สร้างสิ่งประดิษฐ์จะถูกเก็บไว้ใน out/Release/
Directory
สคริปต์จะติดตั้ง bproxy
ใน /usr/local/bin
$ sudo make install
$ ./bproxy
หรือ
$ ./bproxy -c /path/to/bproxy-config.json
{
"port" : 80 ,
"secure_port" : 443 ,
"gzip_mime_types" : [ " text/css " , " application/javascript " , " application/x-javascript " ],
"log_file" : " bproxy.log " ,
"templates" : {
"status_400_template" : " " ,
"status_404_template" : " templates/404.html " ,
"status_502_template" : " "
},
"proxies" : [
{
"hosts" : [
" bleenco.io " ,
" www.bleenco.io "
],
"certificate_path" : " certs/bleenco.io.crt " ,
"key_path" : " certs/bleenco.io.key " ,
"ip" : " 127.0.0.1 " ,
"port" : 7500 ,
"force_ssl" : true
},
{
"hosts" : [ " *.bleenco.io " ],
"ip" : " 127.0.0.1 " ,
"port" : 4550 ,
"ssl_passthrough" : true
}
]
}
คุณสมบัติ force_ssl
เปิดใช้งานการเปลี่ยนเส้นทางจาก HTTP เป็น HTTPS โดยการตอบกลับด้วยสถานะ HTTP 301
คุณสมบัติ ssl_passthrough
เปิดใช้งานเซิร์ฟเวอร์พร็อกซ์ SSL/TLS นั่นหมายความว่าข้อมูลไม่ได้ถูกถอดรหัสหรือแยกวิเคราะห์ แต่เพิ่งส่งต่อไปยังเซิร์ฟเวอร์และในทางกลับกัน นอกจากนี้ยังช่วยให้การเปลี่ยนเส้นทางจาก HTTP เป็น https
$ make docker_image
คุณสามารถดึงภาพจาก Docker Hub เป็น docker pull bleenco/bproxy
หรือสร้างจากแหล่งที่มาตามที่ระบุไว้ในส่วนก่อนหน้า
จากนั้นบนเซิร์ฟเวอร์ของคุณ:
$ docker run -it --name bproxy --net host -v ~/path/to/bproxy.json:/bproxy/bproxy.json -v /var/log/bproxy.log:/var/log/bproxy.log --restart always bleenco/bproxy
$ npm install
$ npm test
The MIT License
Copyright (c) 2018 Bleenco GmbH http://bleenco.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.