【问题标题】:How to set cookie for specific URL path in hapyoxy configuration如何在hapyoxy配置中为特定的URL路径设置cookie
【发布时间】:2019-05-13 00:29:14
【问题描述】:

我有一个在 haproxy 服务器上运行的 WordPress 网站,在运行 httpd 和 MySQL 复制的两台服务器之间进行循环

我发现在上传图片或更改特定相册的视图网格时,在没有在 WordPress 媒体库中设置持久连接的情况下使用 haproxy 时会出现问题。我正在尝试找出是否有可能为特定 URL 设置 cookie 的方法,该 URL 可能是 wp-admin 路径,访问者的网站的其余部分将是循环方法,没有持久连接,以提高负载平衡效率

我当前的 haproxy 配置是

global
    log 127.0.0.1    local0
    log 127.0.0.1    local1 notice
    tune.ssl.default-dh-param 1024
    maxconn 4096
    user haproxy
    group haproxy
    daemon

defaults
    log    global
    mode    http
    option    httplog
    option    dontlognull
    option forwardfor
    option http-server-close
    timeout http-request    30s
    timeout queue           1m
    timeout connect         30s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 0s
    timeout check           30s

#---------------------------------------------------------------------
# HAPROXY STATS
#---------------------------------------------------------------------

listen webfarm 192.168.1.2:80
       mode http
       stats enable
       stats uri /haproxy?stats
       stats realm Haproxy\ Statistics
       stats auth username:password

#---------------------------------------------------------------------
# WEBSERVER
#---------------------------------------------------------------------

frontend https-in
    bind *:443 transparent ssl crt /etc/ssl/private/website.pem
    #reqadd X-Forwarded-Proto:\ https
    default_backend https-backend

backend https-backend
    balance roundrobin
    option httpclose
    option forwardfor
    cookie website.com insert indirect nocache

    #enter the IP of your application here
    server web01 192.168.1.2:443 maxconn 1024 check ssl verify none
    server web02 192.168.1.3:443 maxconn 1024 check ssl verify none

我的问题是如何为任何包含 wp-admin 正则表达式的 URL 启用 cookie?

【问题讨论】:

    标签: wordpress centos load-balancing haproxy


    【解决方案1】:

    您可以使用“ignore-persist”执行相反的操作并忽略某些 URL 的 cookie 持久性:https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#ignore-persist

    【讨论】:

      猜你喜欢
      • 2013-08-29
      • 2016-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-15
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多