nginx - 如何让 Nginx 将 https 流量作为 https 代理服务器转发到上游?
问题描述
在这里,我想设置一个带有 nginx 作为负载均衡器的 Tor 集群,以提供 HA tor 服务。我选择“ https://github.com/reiz/nginx_proxy ” nginx 模块来提供 https_proxy 功能。它适用于 https 连接。但没有将 https 流量转发到上游。
发生了什么:
情况1:
当我运行下面的 cmd 时,它将从上游 tor 服务返回一个随机 ip,它适用于 http 流量。
curl -x localhost:8090 http://api.ipify.org
案例二:
它因 https 流量而失败,我可以从访问日志中看到
"CONNECT api.ipify.org:443 HTTP/1.1" 200 6176 "-" "curl/7.54.0" "-"
是的,作为 https 代理,nginx 可以工作,但无法将 https 流量转发到上游的 Tor。下面的命令总是返回相同的 ip,即我电脑的当前 ip。
curl -x localhost:8090 https://api.ipify.org
那么,我想要的是,如何让 nginx 将 https 流量转发到上游?
nginx.conf
user www-data;
worker_processes auto;
daemon off;
events {}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
include /usr/local/nginx/conf/conf.d/*.conf;
}
默认.conf
upstream torProxy {
server tor-cluster_tor_1:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_2:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_3:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_4:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_5:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_6:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_7:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_8:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_9:8118 max_fails=3 fail_timeout=30s;
server tor-cluster_tor_10:8118 max_fails=3 fail_timeout=30s;
}
server {
listen 8090;
proxy_connect;
proxy_max_temp_file_size 0;
resolver 8.8.8.8;
location / {
proxy_pass http://torProxy;
proxy_set_header Host $http_host;
proxy_set_header Authorization "";
}
}
解决方案
推荐阅读
- assembly - 8086 不打印第一个字符,而是打印空值
- r - %*%+ 在矩阵运算中是什么意思?
- laravel-5 - 在远程主机上安装 laravel 5.6 应用程序时出错
- string - 从批处理文件到双引号的firefox和google
- firebase - firestore 与 firebase-functions 和 firebase-admin 有什么区别?
- hibernate - 一个集合中的多个实体类型与 JPA
- shell - 脚本在通过 crontab 运行时不通过邮件给出结果
- c# - C# 数据库应用程序
- chef-infra - 厨师客户端运行后从厨师缓存中删除大文件
- python - 为什么“tkinter.scrolledtext.ScrolledText() 不起作用,我必须先明确导入它,如“从 tkinter 导入滚动文本”