HAproxy for onlyoffice Virtual path


#1

Here is examples for nginx and apache, but I need for haproxy
https://helpcenter.onlyoffice.com/server/document/document-server-proxy.aspx

My haproxy.cfg

global
maxconn 16384
tune.ssl.default-dh-param 2048
log 127.0.0.1 local1 debug
stats socket /var/run/haproxy_info.sock mode 666 level user
stats timeout 2m

defaults
maxconn 16384
timeout client 5s
timeout connect 5s
timeout queue 5s
timeout server 30s
timeout tunnel 1h
log global

frontend cloud
bind *:80
mode http
acl is_oo path_beg /oo
option forwardfor header X-Real-IP
use_backend ooffice if is_oo
default_backend cloudnodes

backend cloudnodes
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
cookie SERVERID insert indirect nocache
server own-01 1.2.3.40:80 check cookie own-01 check inter 1000 rise 1 fall 1
server own-02 1.2.3.41:80 check cookie own-02 check inter 1000 rise 1 fall 1

backend ooffice
mode http
option httpclose
option forwardfor header X-Real-IP
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-For %[src]
http-request set-header X-Client-IP %[src]
http-request set-header X-Forwarded-Proto http
http-request set-header Forwarded proto=http
http-request add-header Host %[src]
http-request add-header X-Forwarded-Host %[src]
http-request add-header X-Forwarded-Server %[src]
reqrep ^([^\ :])\ /oo(.) \1\ \2
server oo-01 1.2.3.4:80


#2

Moved to Help section, as you are asking for a configuration, rather than providing a working configuration.


#3

I have resolved my problem. Working config below:

frontend default_port_80
mode http
bind :80
acl oo path_beg /oo
use_backend ooffice if oo
default_backend default_service

backend default_service
mode http
balance roundrobin
cookie SERVERID insert indirect nocache
server own-01 IP_ownc:80 check cookie own-01 check inter 1000 rise 1 fall 1

backend ooffice
mode http
acl existing-x-forwarded-host req.hdr(X-Forwarded-Host) -m found
http-request add-header X-Forwarded-Host %[req.hdr(Host)]/oo unless existing-x-forwarded-host
reqrep ^([^\ :])\ /oo/(.) \1\ /\2
server onlyoffice-documentserver IP_documentserver:80