我正在尝试限制对特定 URL 的访问。它不应该被允许访问/admin.php。
frontend example
acl restricted_page path_beg -i /admin\.php
http-request deny if restricted_page
Run Code Online (Sandbox Code Playgroud)
这工作正常,HAProxy 阻止访问此 URL。但是当我输入http://example.org/ad%6Din.php(%6D = "m" 的十六进制代码)时,HAProxy 不会限制访问。
做这个的最好方式是什么?
谢谢!
我想将 GoAccess 与 Haproxy 一起使用,它用作反向代理和负载平衡器。
我的目标是创建一个自定义日志格式,它看起来与 apache2 完全一样(与默认的 goaccess 设置兼容)。
到目前为止我做到了
capture request header Referrer len 64
capture request header Content-Length len 10
capture request header User-Agent len 64
log-format %si:%sp\ %ci\ -\ -\ [%t]\ "%r"\ %ST\ %B\ "%%Referrer"\ "%%User-Agent"
Run Code Online (Sandbox Code Playgroud)
我的 haproxy 版本是 HA-Proxy 版本 1.5.14 2015/07/02
我不知道如何从捕获的请求中提取引用者和用户代理。我在手册中找不到任何关于自定义日志格式的有用信息。
编辑
我发现 %hrl 是捕获的请求标头的字符串列表。是否可以通过键或索引提取值?
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
option redispatch
errorfile …Run Code Online (Sandbox Code Playgroud) 在 CentOS 7 Linux 上,我在通过 FastCGI 为 Wordpress 站点提供服务的Jetty 9前面成功使用了 HAProxy 1.5.14 。
它工作得非常好,但是对于同一网站上的 HTML5/WebSocket 游戏,WebSocket 连接到/ws/URL 的客户端和服务器超时需要更高的时间。
所以我将/etc/haproxy/haproxy.cfg文件修改为以下内容:
global
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
tune.ssl.default-dh-param 2048
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m # HOW TO INCREASE FOR /ws/ ?
timeout …Run Code Online (Sandbox Code Playgroud) 当我在 Ubuntu 服务器上配置 ha-proxy 的代理服务器时,我忘记在haproxy.cnf 文件中选择一个平衡选项 ,但是窃取工作正常,有人知道正在运行什么算法吗?
我有两台具有相同 URL 的服务器,但端口号可能会更改。
我想重定向这两个 URL HTTPS。
如果我输入我的第一个 URL ( http://example.com) 那么我希望它会重定向到https://example.com.
如果我输入第二个 URL ( http://example.com:8080) 然后我希望它重定向到https://example.com:8080.
查看我的配置:
frontend www-HTTP
bind *:80
bind *:443 ssl crt /etc/apache2/ssl/apache.pem
reqadd X-Forwarded-Proto:\ https
default_backend tcp-backend
mode tcp
frontend TCP-HTTP
bind *:8080
bind *:8443 ssl crt /etc/apache2/ssl/paritech.pem
reqadd X-Forwarded-Proto:\ https
default_backend www-backend
mode tcp
backend www-backend
redirect scheme https if !{ ssl_fc }
server dev.example.com 192.168.1.120:8080 check
backend TCP-backend
redirect scheme https if !{ ssl_fc }
server qa.example.com 192.168.1.120:80 …Run Code Online (Sandbox Code Playgroud) 我可能已经迷失在关于这个主题的大量文档中,但我正在尝试配置我的 HAProxy 进程以发送代理协议标头,如http://www.haproxy.org/download/1.8/doc/ 所述代理协议.txt。这是因为我必须将 PROXY 协议的支持写入 C++ 服务器(以便它能够访问客户端 IP/端口),并且我想测试我的代码在解析 PROXY 标头时是否正常工作。
这是我的最小配置文件:
global
maxconn 4096
defaults
log global
mode http
retries 3
option redispatch
maxconn 2000
timeout connect 5000
timeout client 50000
timeout server 50000
frontend TestServerTest
bind 10.6.186.24:54781
mode tcp
default_backend TestServernodes
backend TestServernodes
mode tcp
# Note there is no 'check' after the below line unlike the others as we don't want to send the
# healthcheck ("OPTIONS / HTTP/1.0"...) string to the TestServer as it …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 HAProxy 设置传递代理。
版本:- HA-Proxy 版本 1.7.5 2017/04/03
我有两个 URL abc.com/foo 和 abc.com/bar,我希望它被重定向到我的后端服务器,这些服务器以 10.0.0.1/xyz/ 的形式提供请求
例如,如果我的请求是作为 abc.com/foo/login 来的,那么这个请求应该作为 10.0.0.1:7003/xyz/login 进入我的后端服务器,但前端应该只显示 abc.com/foo/login .
我尝试在下面使用
"http-request redirect code 301 location http://%[hdr(host)]%[url,regsub(^/foo/,/bar/,)] if { path_beg /foo }"
Run Code Online (Sandbox Code Playgroud)
但它正在将 URL 更改为 abc.com/xyz
到目前为止我一直在使用 nginx,下面是我的相同配置。
server {
listen 8443;
underscores_in_headers on;
location /Recharge {
proxy_pass http://backend/RetailerApp;
proxy_read_timeout 15;
}
location /Gateway {
proxy_pass http://backend/RetailerApp;
proxy_read_timeout 15;
}
}
upstream backend_preprod {
server 10.5.214.237:7005;
server 10.5.214.237:7004;
}
Run Code Online (Sandbox Code Playgroud) 我想以 tcp 模式将真实客户端的 IP 地址从 haproxy 转发到我的后端服务器。Haproxy的配置如下:
frontend main
bind *:80
mode http
option forwardfor
option http-server-close
default_backend app-main
frontend https_main
bind *:443
mode tcp
option tcplog
option tcpka
default_backend app-ssl
backend app-main
balance roundrobin
server web1 192.168.1.22:8080 check fall 3 rise 2
server web2 192.168.1.33:8080 check fall 3 rise 2
backend app-ssl
balance roundrobin
mode tcp
option ssl-hello-chk
server web3 192.168.1.44:443
Run Code Online (Sandbox Code Playgroud)
http 请求的后端服务器是 apache,我用日志行替换了 httpd.conf 中的以下行,所以我现在可以正确获取客户端的 ip 地址:
LogFormat "%h %l %u %t \"%r\" %>s %b %{X-Forwarded-For}i" common
Run Code Online (Sandbox Code Playgroud)
我的 …
是否可以监控HTTP 请求的持续时间?(从负载均衡器收到请求的那一刻起,到负载均衡器将响应返回给客户端的那一刻)
我想在前端监控这个指标,因为我想包括排队时间。如果我测量后端的持续时间,我可能会得到很好的统计数据,但实际性能可能很差(例如,如果请求在负载均衡器本身中排队)。
例如,我想在流量高峰期间监控 Web 应用程序,以确保从用户的角度来看响应仍然很快(例如 < 3 秒)。