具有原始主机名的HA代理TCP余额

时间:2018-07-02 15:15:52

标签: tcp haproxy sticky splunk balance

我有一个带有3个节点的Splunk搜索头群集,并且我正在尝试设置一个HA代理实例以使用户登录到这3个搜索头节点之一中。

  • Splunk 7.1
  • HA代理1.5.18
  • Centos 7

代理本身正在工作,并根据splunk运行状况(在端口8300上运行splunk)路由以更正SH节点

问题是,如果我转到“ splunk.company.local”(HA代理DNS名称),则HAproxy会将用户重定向到3个节点之一,但不会在URL中保留“ splunk.company.local” ,网址改为“ splunksh01.company.local”等,

我无法弄清楚如何使用单个粘性名称,因此用户始终位于“ splunk.company.com” URL下,并且从未看到实际的SH节点主机名,

haproxy.cfg

# This file managed by Puppet
global
  daemon  
  debug  true
  group  haproxy
  log  10.185.20.168 local0
  pidfile  /var/run/haproxy.pid
  stats  socket /var/lib/haproxy/stats
  user  haproxy

defaults
  log  global
  maxconn  8000
  mode  tcp
  option  redispatch
  retries  3
  timeout  connect 15s
  timeout  client 50s
  timeout  server 50s
  timeout  check 10s
  timeout  server 1m

listen splunk
  bind 0.0.0.0:80 

  mode tcp
  balance source
  server splunksh01.company.local 10.185.20.173:80 check port 8300
  server splunksh02.company.local 10.185.20.174:80 check port 8300
  server splunksh03.company.local 10.185.20.176:80 check port 8300

现在在每个SH节点上,我都通过Apache反向代理运行Splunk,

cat /etc/httpd/conf.d/splunk.conf

<VirtualHost *:443>
  ServerName splunk

  ## Logging
  ErrorLog "/var/log/httpd/splunk-443_error_ssl.log"
  ServerSignature Off
  CustomLog "/var/log/httpd/splunk-443_access_ssl.log" combined 

  ## Request header rules
  ## as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#requestheader
  RequestHeader set X-Forwarded-Proto "https"

  ## Proxy rules
  ProxyRequests Off
  ProxyPreserveHost Off
  ProxyPass / https://splunksh01.company.local:8300/
  ProxyPassReverse / https://splunksh01.company.local:8300/

  ## SSL directives
  SSLEngine on
  SSLCertificateFile      "/etc/puppetlabs/puppet/ssl/certs/splunksh01.company.local.pem"
  SSLCertificateKeyFile   "/etc/puppetlabs/puppet/ssl/private_keys/splunksh01.company.local.pem"

  # SSL Proxy directives
  SSLProxyEngine On
</VirtualHost>

一旦HAproxy将请求路由到其中一个节点,如何保留相同的主机名?谢谢。

0 个答案:

没有答案