Indy HTTP代理服务器,如何设置密码?
我正在考虑编写代理服务器。当我使用tidhttpproxyserver
组件指定和激活端口时,代理服务器正常工作。到目前为止还可以,但是我无法密码,也无法打开IPV6代理。这只是IPv4代理。我找不到太多的文档。
I'm thinking of writing a Proxy Server. When I specify and activate the port using the TIdHTTPProxyServer
component, the proxy server works properly. It's okay so far, but I can't password it and I can't open an IPv6 proxy. It's just an IPv4 proxy. I couldn't find much documentation on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
tidhttpproxyserver
当前没有自己的任何身份验证。客户端和目标服务器之间的HTTP身份验证在其中两个之间透明地处理,
tidhttpproxyserver
不参与该过程。如果要密码保护代理本身,则必须在代理的
onhttpbeforecommand
事件中手动处理身份验证。检查客户端的请求标头(在事件的acontext.headers
属性中)中的proxy-oterorization
标题,如果不存在或其凭据失败,则可以手动发送客户端(通过acontext.connection
属性)http407
响应包含适当的proxy-authenticate
header,然后rise
repand/code>异常(或断开
acontext.connection
)以停止处理当前代理请求。tidhttpproxyserver
可以同时处理IPv4和ipv6,但需要进行一些手动设置。默认情况下,默认情况下,在global
id_default_ip_ip_version
Indy的iDglobal
unit中指定了默认情况下的任何IP版本Indy(除非设置为IPv4) 在IDCOMPILERDEFINES.inc
中定义的)。可以在代理的
bindings
集合中配置IP/端口对。您可以为每个绑定指定iPversion
。iPversion
设置为iD_DEFAULT_IP_VERSION
默认情况下。如果未指定任何
bindings
条目,则代替代理的defaultport
属性。然后,代理将根据平台和操作系统功能打开1或2个侦听端口。如果打开1个端口,它将使用id_default_ip_version
。如果打开了2个端口,则1个为IPv4,1为IPv6。因此,如果您想控制侦听IP/端口的设置,请不要将
bindings
空。客户端连接到侦听端口后,
tidhttpproxyservercontext.outboundclient
用于连接到下一个HTTP服务器的对象将使用ID_DEFAULT_IP_VERSION
默认情况下。您可以通过将事件的acontext.OutBoundClient
属性施放到tidtcpclient
,然后设置其ipversion
ipversion ipversion ipversion ipversion ipversion ipversion /代码>属性。TIdHTTPProxyServer
does not currently implement any authentication of its own.HTTP authentication between the client and target server is handled transparently between the two of them,
TIdHTTPProxyServer
is not involved in that process.If you want to password-protect the proxy itself, you will have to manually handle authentication in the proxy's
OnHTTPBeforeCommand
event. Check the client's request headers (in the event'sAContext.Headers
property) for aProxy-Authorization
header, and if it is not present, or its credentials fail, then manually send the client (via theAContext.Connection
property) an HTTP407
response containing an appropriateProxy-Authenticate
header, and thenraise
an exception (or disconnect theAContext.Connection
) to stop processing the current proxy request.TIdHTTPProxyServer
can handle both IPv4 and IPv6, but it will require some manual setup.Whichever IP version Indy is compiled for by default is specified in the global
ID_DEFAULT_IP_VERSION
constant in Indy'sIdGlobal
unit (it is set to IPv4, unless Indy is compiled withIdIPv6
defined inIdCompilerDefines.inc
).Listening IP/port pairs can be configured in the proxy's
Bindings
collection. You can specify anIPVersion
for each binding. TheIPVersion
is set toID_DEFAULT_IP_VERSION
by default.If you don't specify any
Bindings
entries, the proxy'sDefaultPort
property is used instead. The proxy will then open either 1 or 2 listening ports, depending on platform and OS capabilities. If 1 port is opened, it will useID_DEFAULT_IP_VERSION
. If 2 ports are opened, 1 will be IPv4 and 1 will be IPv6.So, if you want control over the setup of the listening IP/ports, don't leave the
Bindings
empty.Once a client has connected to a listening port, the
TIdHTTPProxyServerContext.OutboundClient
object that is used to connect to the next HTTP server will useID_DEFAULT_IP_VERSION
by default. You can override this in the proxy'sOnHTTPBeforeCommand
event, by casting the event'sAContext.OutboundClient
property toTIdTCPClient
and then setting itsIPVersion
property.