Skip to content

Commit

Permalink
Add http pass for cdn proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Oct 25, 2023
1 parent c3fc4c9 commit 9c60973
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions proxy/include/proxy/proxy_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ namespace proxy {
// 是 http proxy,则由 url 指定的 protocol 决定是否使用 ssl.
bool proxy_pass_use_ssl_{ false };

// 指定通过 http pass 作为下级代理, 通常可以使用 cdn 来实现多层代理.
std::string http_pass_;

// 启用 proxy protocol (haproxy)协议.
// 当前服务将会在连接到 proxy_pass_ 成功后,首先传递 proxy protocol 以
// 告之 proxy_pass_ 来源 IP/PORT 以及目标 IP/PORT.
Expand Down
4 changes: 4 additions & 0 deletions server/proxy_server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ std::string socks_passwd;
std::vector<std::string> auth_users;
std::string proxy_pass;
bool proxy_pass_ssl = false;
std::string http_pass;
bool ssl_prefer_server_ciphers = false;
std::string ssl_certificate_dir;

Expand Down Expand Up @@ -98,6 +99,7 @@ start_proxy_server(net::io_context& ioc, server_ptr& server)

opt.proxy_pass_ = proxy_pass;
opt.proxy_pass_use_ssl_ = proxy_pass_ssl;
opt.http_pass_ = http_pass;

opt.ssl_cert_path_ = ssl_certificate_dir;
opt.ssl_ciphers_ = ssl_ciphers;
Expand Down Expand Up @@ -219,6 +221,8 @@ int main(int argc, char** argv)
("proxy_pass", po::value<std::string>(&proxy_pass)->default_value("")->value_name(""), "Specify next proxy pass (e.g: socks5://user:passwd@ip:port).")
("proxy_pass_ssl", po::value<bool>(&proxy_pass_ssl)->default_value(false, "false")->value_name(""), "Enable SSL for the next proxy pass.")

("http_pass", po::value<std::string>(&http_pass)->default_value("")->value_name(""), "Specify next http(s) pass (e.g: https://user:passwd@domain/path).")

("ssl_certificate_dir", po::value<std::string>(&ssl_certificate_dir)->value_name("path"), "Directory containing SSL certificates, auto-locates 'ssl_crt.pem/ssl_crt.pwd/ssl_key.pem/ssl_dh.pem'.")

("ssl_certificate", po::value<std::string>(&ssl_certificate)->value_name("path"), "Path to SSL certificate file.")
Expand Down

0 comments on commit 9c60973

Please sign in to comment.