This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
Darknights-master edited this page Oct 17, 2021
·
9 revisions
1.安装requirements内环境
python 3.x
mongodb
nginx
bottle >= 0.13
pymongo >= 3.11
Crypto
2.配置nginx
自签名证书,域名随意
openssl genrsa -out privkey.pem 2048
openssl req -new -key privkey.pem -out server.csr
openssl x509 -req -in server.csr -out fullchain.pem -signkey privkey.pem -days 3650
server {
listen 80;
server_name 0.0.0.0;
location / {
rewrite ^/(.*) https://$host$1 permanent;
}
}
server {
listen 9443 ssl;
server_name 0.0.0.0;
ssl_certificate fullchain.pem; # ssl证书存储路径
ssl_certificate_key privkey.pem; # 私钥存储路径
location / {
proxy_set_header Host $host;
proxy_set_header X_REAL_IP $remote_addr;
proxy_set_header X_FORWARDED_FOR $proxy_add_x_forwarded_for;
proxy_set_header X_FORWAEDED_PROTO $scheme;
proxy_pass http://localhost:9444;
proxy_read_timeout 90;
}
}
准备证书(可到Let's Encrypt)申请
server {
listen 9443 ssl;
server_name example.com; #你的域名
ssl_certificate fullchain.pem; #你的证书
ssl_certificate_key privkey.pem; #你的私钥
location / {
proxy_set_header Host $host;
proxy_set_header X_REAL_IP $remote_addr;
proxy_set_header X_FORWARDED_FOR $proxy_add_x_forwarded_for;
proxy_set_header X_FORWAEDED_PROTO $scheme;
proxy_pass http://localhost:9444;
proxy_read_timeout 90;
}
}
3.启动mongodb
mongod --dbpath ...
4.启动Server
python main.py
mitmproxy 既可以部署于服务器端,与主服务器进程同时运行,也可以部署于本地.
1.安装mitmproxy
pip install mitmproxy
2.配置脚本
请将脚本中 第七行 remote_server = "example.com"
替换成你服务器的域名或ip
3.启动代理
mitmweb --set ssl_insecure=true --set block_global=false -s Darknights-proxy.py
稍后,您将会看到如下提示,同时打开一个mitmweb的浏览器窗口
Proxy Loaded.
Web server listening at http://127.0.0.1:8081/
Loading script Darknights-proxy.py
Proxy server listening at http://*:8080
使用linux服务器则可能提示No web browser found. Please open a browser and point it to http://127.0.0.1:8081/
如果一切正常,一个http代理将在8080端口开放
4.信任证书