Detailed profiles of haproxy frontend

Configuration example:

frontend www
    bind *:80
    mode http
    option httplog
    option forwardfor
    option httpclose
    log global
    #acl host_www hdr_dom(host) -i www.zb.com
    #acl host_img hdr_dom(host) -i img.zb.com
    #use_backend htmpool if host_www
    #use_backend imgpool if host_img
    default_backend htmpool

This section defines a front-end virtual node named "www" by frontend keywords, here's the meaning of each option.

bind: This option can only be defined in the frontend and listen section, is used to define one or more listening sockets. bind using the format:

  bind [<address>:<port_range>] interface <interface>

  Which, address as selectable options, which can be a host name or IP address, all IPv4 addresses if it is set to "*" or "0.0.0.0", will monitor the current system.

  port_range may be a specific TCP port, but also a range of ports, port less than 1024 requires user specific permission to use.

  interface options are optional, used to specify the name of the network interface, can only be used on Linux systems.

option httplog: By default, haproxy log is not recorded HTTP request, this is very easy to troubleshoot and monitor HAProxy problem. You can enable logging for HTTP requests through this option.

option forwardfor: If the back-end server need to get real IP client, you need to configure this parameter. Since HAProxy work in reverse proxy mode, so the request sent to the backend server's real client IP IP are HAProxy host, rather than a real access to the client's address, which led to the real server was unable to record the client's request real source IP, and "X-Forwarded-for" can be used to solve this problem.

  By using "forwardfor" option, HAProxy can add "X-Forwarded-For" to record every request sent to the backend server's real, so real back-end server logs can be recorded by the customer "X-Forwarded-For" Information end source IP.

option httpclose: This option means that the client and server after the completion of a connection request, HAProxy will take the initiative to close the TCP connection. This is very helpful in a performance parameter.

log global: representation using the global log configuration, where the "global" is a reference to log option to configure the format defined in the global section of the configuration file HAProxy.

default_backend: # specify the default back-end server pool, which is designated a group of real back-end servers, which are the real server group will be defined in the backend segment. Htmpool here is a back-end server group.

Guess you like

Origin www.cnblogs.com/yyxianren/p/10942985.html