|
| 1 | +# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | + |
| 4 | +global |
| 5 | + log stdout local0 info |
| 6 | + maxconn 8192 |
| 7 | + ca-base /etc/ssl/certs |
| 8 | + |
| 9 | +defaults |
| 10 | + log global |
| 11 | + option httplog |
| 12 | + option dontlognull |
| 13 | + timeout connect 30s |
| 14 | + timeout client 30s |
| 15 | + timeout server 1800s |
| 16 | + |
| 17 | + |
| 18 | +############################################################################### |
| 19 | +# FRONTEND: ex_apps (HTTP) |
| 20 | +############################################################################### |
| 21 | +frontend ex_apps |
| 22 | + mode http |
| 23 | + bind 0.0.0.0:8780 |
| 24 | + |
| 25 | + filter spoe engine exapps-spoe config /etc/haproxy/spoe-agent.conf |
| 26 | + http-request silent-drop if { var(txn.exapps.bad_request) -m int eq 1 } |
| 27 | + http-request return status 401 content-type text/plain string "401 Unauthorized" if { var(txn.exapps.unauthorized) -m int eq 1 } |
| 28 | + http-request return status 403 content-type text/plain string "403 Forbidden" if { var(txn.exapps.forbidden) -m int eq 1 } |
| 29 | + http-request return status 404 content-type text/plain string "404 Not Found" if { var(txn.exapps.not_found) -m int eq 1 } |
| 30 | + use_backend %[var(txn.exapps.backend)] |
| 31 | + |
| 32 | +############################################################################### |
| 33 | +# BACKENDS: ex_apps & ex_apps_backend_w_bruteforce |
| 34 | +############################################################################### |
| 35 | +backend ex_apps_backend |
| 36 | + mode http |
| 37 | + server frp_server 0.0.0.0 |
| 38 | + http-request set-path %[var(txn.exapps.target_path)] |
| 39 | + http-request set-dst var(txn.exapps.target_ip) |
| 40 | + http-request set-dst-port var(txn.exapps.target_port) |
| 41 | + http-request set-header EX-APP-ID %[var(txn.exapps.exapp_id)] |
| 42 | + http-request set-header EX-APP-VERSION %[var(txn.exapps.exapp_version)] |
| 43 | + http-request set-header AUTHORIZATION-APP-API %[var(txn.exapps.exapp_token)] |
| 44 | + http-request set-header AA-VERSION "32" # TO-DO: temporary, remove it after we update all ExApps. |
| 45 | + |
| 46 | +backend ex_apps_backend_w_bruteforce |
| 47 | + mode http |
| 48 | + server frp_server 0.0.0.0 |
| 49 | + http-request set-path %[var(txn.exapps.target_path)] |
| 50 | + http-request set-dst var(txn.exapps.target_ip) |
| 51 | + http-request set-dst-port var(txn.exapps.target_port) |
| 52 | + http-request set-header EX-APP-ID %[var(txn.exapps.exapp_id)] |
| 53 | + http-request set-header EX-APP-VERSION %[var(txn.exapps.exapp_version)] |
| 54 | + http-request set-header AUTHORIZATION-APP-API %[var(txn.exapps.exapp_token)] |
| 55 | + http-request set-header AA-VERSION "32" # TO-DO: temporary, remove it after we update all ExApps. |
| 56 | + filter spoe engine exapps-bruteforce-protection-spoe config /etc/haproxy/spoe-agent.conf |
| 57 | + |
| 58 | +############################################################################### |
| 59 | +# BACKEND: nextcloud_control (HTTP) |
| 60 | +############################################################################### |
| 61 | +backend nextcloud_control_backend |
| 62 | + mode http |
| 63 | + server nextcloud_control 127.0.0.1:8200 |
| 64 | + http-request set-path %[var(txn.exapps.target_path)] |
| 65 | + |
| 66 | +############################################################################### |
| 67 | +# BACKEND: docker_engine (HTTP) |
| 68 | +############################################################################### |
| 69 | +backend docker_engine_backend |
| 70 | + mode http |
| 71 | + server frp_server 127.0.0.1 |
| 72 | + http-request set-dst-port var(txn.exapps.target_port) |
| 73 | + http-request set-path %[var(txn.exapps.target_path)] |
| 74 | + |
| 75 | + # docker system _ping |
| 76 | + http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/_ping$ } METH_GET |
| 77 | + # docker inspect image |
| 78 | + http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/images/.*/json } METH_GET |
| 79 | + # container inspect: GET containers/%s/json |
| 80 | + http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/nc_app_[a-zA-Z0-9_.-]+/json } METH_GET |
| 81 | + # container inspect: GET containers/%s/logs |
| 82 | + http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/nc_app_[a-zA-Z0-9_.-]+/logs } METH_GET |
| 83 | + |
| 84 | + # image pull: POST images/create?fromImage=%s |
| 85 | + http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/images/create } METH_POST |
| 86 | + http-request deny |
| 87 | + |
| 88 | + |
| 89 | +backend agents |
| 90 | + mode tcp |
| 91 | + timeout connect 5s |
| 92 | + timeout server 3m |
| 93 | + option spop-check |
| 94 | + server agent1 127.0.0.1:9600 check |
0 commit comments