Cal*_*pin 5 nginx reverse-proxy
我在代理服务器后面有一组应用程序,它们适当地转发请求并使用代理协议来保留请求的原始数据。这些应用程序还会相互发出请求,因此我希望它们接受使用和不使用代理协议的请求。是否可以将 Nginx 配置为以某种方式执行此操作而不使用其他server_name
端口?
在不使用不同server
块的情况下,执行此操作的唯一方法是使用不同的listen
指令。这意味着运行 nginx 的服务器必须具有不同的 IP 地址才能从外部代理和内部服务器场连接到服务器。
例如,您的内部应用程序可能有一个内部网络 10.87.239.0/24,而运行 nginx 的服务器位于 10.87.239.3。然后,您有一个外部网络 10.87.238.0/24,您的外部代理服务器使用它来访问 nginx,并且该服务器的地址为 10.87.238.3。在这种情况下,您可以将 nginx 配置为:
server {
# PROXY protocol connections
listen 10.87.238.3:443 ssl http2 proxy_protocol;
set_real_ip_from 10.87.238.2; # The address(es) of the proxies
real_ip_header proxy_protocol;
# Direct connections
listen 10.87.239.3:443 ssl http2;
listen [::]:443 ssl http2;
# everything else for this block
}
Run Code Online (Sandbox Code Playgroud)
与此相关的是,即使没有全球 IPv6 连接,您也应该已经在组织内部署了 IPv6。如果您没有单独的内部 IPv4 网络,您可以将其用于内部通信。
小智 6
代理协议中的代理协议规范明确指出了运行尝试猜测代理协议是否在同一地址和端口上使用的侦听器的风险。
The receiver MUST be configured to only receive the protocol described in this
specification and MUST not try to guess whether the protocol header is present
or not. This means that the protocol explicitly prevents port sharing between
public and private access. Otherwise it would open a major security breach by
allowing untrusted parties to spoof their connection addresses. The receiver
SHOULD ensure proper access filtering so that only trusted proxies are allowed
to use this protocol.
Run Code Online (Sandbox Code Playgroud)
因此,尝试接受带有和不带有代理协议的请求都会存在风险。
归档时间: |
|
查看次数: |
979 次 |
最近记录: |