标签: proxy

使用 mod_proxy_ajp,如何设置“特殊”AJP 属性?

我已经设置了一个Apache Web Server 2.4来充当Apache Tomcat 7 的代理,通过AJP协议( ​​Apache 端的mod_proxy_ajp和 Tomcat 端的 AJP 连接器)进行通信。一切都非常适合基本功能。

现在,我希望设置一些特定的 AJP 属性,但无法完全使其工作......


查看mod_proxy_ajp页面(http://httpd.apache.org/docs/current/mod/mod_proxy_ajp.html),在请求数据包结构部分下,我看到属性列表。这些属性包括诸如remote_user和ssl_cert之类的属性(代码值分别为0x03和0x07)。还有一个名为req_attribute的“所有其他”属性,其代码值为0x0A,可用于设置 AJP 请求中的任意属性。

此外,在同一页面的“环境变量”部分下,它声明了以下内容:

名称具有前缀 AJP_ 的环境变量将作为 AJP 请求属性转发到源服务器(从键名称中删除 AJP_ 前缀)。

这看起来很简单,事实上,我可以通过设置名为“AJP_doug-attribute”的 Apache 环境变量并分配相关值来轻松设置任意 AJP 属性,例如“doug-attribute”。完成此操作后,我可以使用 Wireshark 分析流量,并看到剖析的 AJP 块中显示的“doug-attribute”字段,前缀为十六进制值 0x0A(上面列出的“req_attribute”类型)。到目前为止,一切都很好。


现在我想尝试设置ssl_cert属性。以同样的方式,我设置了一个名为“AJP_ssl_cert”的环境变量。这样做后,它确实会显示在 Wireshark 中,但带有前缀代码“0x0A”。此外,我想要读取“javax.servlet.request.x509certificate”的 Java 应用程序找不到该证书。

但是,我还注意到网站上列出的Wireshark捕获中的一些其他属性,例如ssl_cipher和ssl_key_size。但在捕获中,它们显示为“SSL-Cipher”和“SSL-Key-Size”(并具有适当的“0x08”和“0x0B”前缀代码)。因此,我尝试再次设置 cert …

apache ssl proxy ajp mod-proxy-ajp

6
推荐指数
0
解决办法
1241
查看次数

在 Go 中读取缓冲区并将其重写为 http.Response

我想用 golang 编写一个 HTTP 代理。我使用此模块作为代理: https: //github.com/elazarl/goproxy。当有人使用我的代理时,它会调用一个以 http.Response 作为输入的函数。我们称之为“resp”。resp.Body 是一个 io.ReadCloser。我可以使用它的 Read 方法将其读入 []byte 数组。但随后它的内容就从 resp.Body 中消失了。但我必须返回一个 http.Response 以及我读入 []byte 数组的正文。我怎样才能做到这一点?

问候,

最大限度

我的代码:

proxy.OnResponse().DoFunc(func(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Response {

   body := resp.Body
   var readBody []byte
   nread, readerr := body.Read(readBody)
   //the body is now empty
   //and i have to return a body
   //with the contents i read.
   //how can i do that?
   //doing return resp gives a Response with an empty body
}
Run Code Online (Sandbox Code Playgroud)

proxy http go

6
推荐指数
1
解决办法
3240
查看次数

Windows 上的 RStudio 代理配置

这个问题已在:Configure proxy on Rstudio中提出。然而,这个问题始终没有得到解决。

RStudio 0.99.486我是版本和版本的用户R 3.2.2。在阅读了一些建议后,我尝试了两种在办公室配置代理设置的方法,但没有成功:

第一次尝试:在第一行输入 Rstudio:Sys.setenv(http_proxy="http://user_name:password@proxy.company_domain.es:8080/")

转到:-Tools、-Global Options、-Packages,然后取消标记选项:

“使用 Internet 库/HTTP 代理”

我还取消标记了选项:“使用 HTTP 的安全下载方法”。

另外,我右键R x64 3.2.2桌面图标,在“目标”阵营的1个空格后添加:

http_proxy=http://user_name:password@proxy.company_domain.es:8080/

当我收到消息时它不起作用:

install.packages 中的警告:无法打开:HTTP 状态为“407 需要代理身份验证”

第二次尝试:创建一个记事本文件,名称为:

.Renviron

保存在:"C:\Users\username\Documents".

该文件包含以下两行:

http_proxy=http://proxy.company_domain.es/
http_proxy_user=user_name:password
Run Code Online (Sandbox Code Playgroud)

当我尝试安装软件包时,我收到:

“install.packages 中的警告:无法连接到端口 80 上的‘cran.rstudio.com’。无法访问存储库http://cran.rstudio.com/src/contrib的索引”

运行代码行后:R.home()我的 R_HOME 路线是:

“C:/Program Files/R/R-32~1.2”

我预先感谢您的建议和帮助。

settings proxy r rstudio

6
推荐指数
1
解决办法
2万
查看次数

Apache Websocket 代理断开连接

我正在尝试通过 Apache 2.4.7(在 Ubuntu 上运行)代理 websocket。连接已正确建立,但如果浏览器或服务器在一段时间内(几分钟)没有相互发送数据,则来自服务器的新消息不会传递到浏览器。
此外,浏览器或服务器上的服务似乎也没有意识到连接在某种程度上被破坏了(它们根本不会抛出任何错误)。

如何配置服务器以避免此问题?

这是我的配置:

ProxyRequests Off
ProxyPass /somepath ws://127.0.0.1:6080/ retry=60 keepalive=On timeout=9999 ttl=9999
ProxyPassReverse /somepath ws://127.0.0.1:6080/ retry=60
Run Code Online (Sandbox Code Playgroud)

apache proxy mod-proxy proxypass websocket

6
推荐指数
1
解决办法
5363
查看次数

如何将代理身份验证传递给 python 请求模块

我正在处理使用请求模块执行获取/发布到网站的现有 python 代码。

python 代码还允许在将代理传递给脚本时使用代理,否则不使用代理。

我的问题是关于使用需要身份验证的代理。

proxy = user:password@ip:port
self.s = requests.Session()
if proxy != "":
      self.proxies = {
        "http": "http://" + proxy,
        "https": "https://" + proxy
      }
      self.s.proxies.update(proxies)

self.s.get('http://checkip.dyndns.org')
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,如果配置了代理,每个get 都会被拒绝,因为没有提供身份验证。

我找到了一个暗示使用 HTTPProxyAuth 的解决方案。

这是我找到的解决方案:

import requests
s = requests.Session()

proxies = {
  "http": "http://ip:port",
  "https": "https://ip:port"
}

auth = HTTPProxyAuth("user", "pwd")
ext_ip = s.get('http://checkip.dyndns.org', proxies=proxies, auth=auth)
print ext_ip.text
Run Code Online (Sandbox Code Playgroud)

我的问题是:是否可以全局设置代理授权而不是修改代码中的每个s.get?因为有时脚本可以在没有代理的情况下使用,有时也可以使用代理。

提前致谢!

最好的问候,费德里科

python authentication proxy python-requests

6
推荐指数
1
解决办法
1万
查看次数

Docker 构建错误:“无法连接到服务器”(在代理后面)

上下文: 操作系统:Windows 10 Pro;Docker 版本:18.09.0(构建 4d60db4);在企业代理的背后,使用CNTLM来解决这个问题。(目前正在拉/运行图像工作正常)

问题: 我试图构建以下 Dockerfile:

FROM alpine:3.5
RUN apk add --update \
    python3
RUN pip3 install bottle
EXPOSE 8000
COPY main.py /main.py
CMD python3 /main.py
Run Code Online (Sandbox Code Playgroud)

这是我得到的:

Sending build context to Docker daemon  11.26kB
Step 1/6 : FROM alpine:3.5
 ---> dc496f71dbb5
Step 2/6 : RUN apk add --update     python3
 ---> Running in 7f5099b20192
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/main: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.c51f8f92.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz …
Run Code Online (Sandbox Code Playgroud)

dns proxy docker alpine-linux

6
推荐指数
1
解决办法
3542
查看次数

如何在 Python 请求上轮换代理

我正在尝试进行一些抓取,但每 4 个请求就会被阻止。我试图更改代理,但错误是一样的。我应该怎么做才能正确更改它?

这是我尝试的一些代码。首先,我从一个免费的网络获取代理。然后我使用新代理执行请求,但它不起作用,因为我被阻止了。

from fake_useragent import UserAgent
import requests

def get_player(id,proxy):
    ua=UserAgent()
    headers = {'User-Agent':ua.random}

    url='https://www.transfermarkt.es/jadon-sancho/profil/spieler/'+str(id)

    try:
        print(proxy)
        r=requests.get(u,headers=headers,proxies=proxy)
    execpt:

....
code to manage the data
....
Run Code Online (Sandbox Code Playgroud)

获取代理

def get_proxies():
    ua=UserAgent()
    headers = {'User-Agent':ua.random}
    url='https://free-proxy-list.net/'

    r=requests.get(url,headers=headers)
    page = BeautifulSoup(r.text, 'html.parser')

    proxies=[]

    for proxy in page.find_all('tr'):
        i=ip=port=0

    for data in proxy.find_all('td'):
        if i==0:
            ip=data.get_text()
        if i==1:
            port=data.get_text()
        i+=1

    if ip!=0 and port!=0:
        proxies+=[{'http':'http://'+ip+':'+port}]

return proxies
Run Code Online (Sandbox Code Playgroud)

调用函数

proxies=get_proxies()
for i in range(1,100):
    player=get_player(i,proxies[i//4])

....
code to manage the data  
....
Run Code Online (Sandbox Code Playgroud)

我知道代理抓取很好,因为当我打印时,我会看到类似的内容: …

python proxy http-proxy web-scraping python-requests

6
推荐指数
3
解决办法
1万
查看次数

如何限制 Chrome 中的并发(并行)浏览器请求?

背景

我注意到几乎所有的代理提供程序都允许“最大线程数”的概念,根据我的理解,这意味着一次并发/并行浏览器请求的最大数量。由于现代网站可以有许多并行请求,我如何在 Chrome 中限制并行请求(全局针对整个浏览器,不仅针对每个主机/服务器,而且针对所有这些请求的组合)?

例子

网站 A 从自己的域中获取资源,此外还使用了 9 个 CDN 和 10 个跟踪器。假设 Chrome 有最多 6 个并发请求/域,所以这是 120 个并发请求。高于此的任何事情都必须等待轮到它。例如,我想将其限制为最多 10 个。

笔记

我已经看到在 Firefox 中可以使用“ network.http.max-connections ”来完成,但我没有找到适用于 Chrome 或 Chromium 的任何东西。

如果有帮助,我正在使用 Selenium 和 ChromeDriver (C#) 来启动浏览器。

proxy selenium google-chrome chromium selenium-chromedriver

6
推荐指数
2
解决办法
1489
查看次数

在 RHEL7 上使用 pip 安装 boto3 时出错 - 隧道连接失败:502 Bad Gateway

我正在尝试在运行 RHEL7.6 的 ec2 实例上安装 boto3。我在代理后面,代理信息在/etc/environment中列出。我确定代理正在工作。我能够卷曲https://pypi.org并定期使用我们的代理。我正在运行 Python 2.7.5 和 Pip 8.1.2。

我运行以下命令来生成 502 Bad Gateway:
pip install --proxy http://<redacted-ip>:<redacted-port> -v --log pipinstall1.log boto3

我已经包含了 --proxy 标志,因为我在没有它的情况下遇到了相同的错误。我想确定 pip 使用了代理,但无济于事。


对于直接粘贴日志,我深表歉意,但我无法使用托管服务来附加日志文件。

  Collecting boto3
  1 location(s) to search for versions of boto3:
  * https://pypi.python.org/simple/boto3/
  Getting page https://pypi.python.org/simple/boto3/
  Looking up "https://pypi.python.org/simple/boto3/" in the cache
  Returning cached "301 Moved Permanently" response (ignoring date and etag information)
  Looking up "https://pypi.org/simple/boto3/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.org
  Incremented …
Run Code Online (Sandbox Code Playgroud)

proxy pip amazon-web-services python-3.x boto3

6
推荐指数
1
解决办法
2077
查看次数

如何使用 Python/Selenium 设置代理身份验证用户名:密码

我在用:

  • 硒 4
  • 蟒蛇 3.7
  • 火狐网络驱动程序

我需要验证当前项目的用户名和密码。我已经日以继夜地工作了几天,我无法解决这个问题。我在互联网上找到了一些扩展,但它是 13 年的,我想这就是它不起作用的原因。您还可以在下面看到我尝试过的其他方法。

但不起作用,因为由于 Selenium 错误,代理身份验证不再起作用。

alert_popup = browser.switch_to_alert()
    alert_popup.send_keys(
        "{username}{tab}{password}{tab}".format(
            username=proxy_username, tab=Keys.TAB, password=proxy_password
    )
)
alert_popup.accept()
Run Code Online (Sandbox Code Playgroud)

我想创建一个配置文件并手动保存代理信息并使用该配置文件启动 selenium。但是,firefox 不允许手动输入用户名和密码。

python firefox proxy selenium

6
推荐指数
2
解决办法
3616
查看次数