wordpress - 如何在hapyoxy配置中为特定的URL路径设置cookie

标签 wordpress centos load-balancing haproxy

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

我发现在上传图片或更改特定相册的 View 网格时,在没有在 WordPress 媒体库中设置持久连接的情况下使用 haproxy 时会出现问题。我正在尝试找出是否有可能为特定 URL 设置 cookie,可能是 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?

最佳答案

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

关于wordpress - 如何在hapyoxy配置中为特定的URL路径设置cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56104565/

相关文章:

wordpress - 自定义 WordPress 图像大小未显示在 3.5 媒体管理器中

wordpress - 跨源资源共享策略 : No 'Access-Control-Allow-Origin

grep - 在所有文件中搜索特定文本

Azure - 超小型实例 Web 角色 - 准备好用于生产了吗?

javascript - wpbakery visual composer 5.4.7 前端编辑器不工作只显示 Logo

php - 多个 WordPress 循环

centos - iptables 重定向本地连接

python - Django 教程 : problems accessing development server

docker - NiFi集群Docker负载均衡配置

node.js - 找不到 vrrp_instance VI_1 的接口(interface) eth0