1
0
Fork 0

Add protocol support and improve FastCGI plugin handling

- Introduced `easyhaproxy.proto` annotation for backend protocol configuration.
- Automatically set FastCGI protocol (`proto: fcgi`) when using the FastCGI plugin.
- Updated Kubernetes processor to handle `proto` annotations.
- Enhanced EasyMapping to allow plugin overrides for host-level configs.
- Updated documentation to reflect new `proto` behavior and FastCGI improvements.
- Improved multiprocessing configuration with better context handling in `haproxy.py`.
This commit is contained in:
Joao Gilberto Magalhaes 2026-06-24 21:21:27 -04:00
parent 2b7b2c887f
commit e4b62a3925
8 changed files with 33 additions and 14 deletions

View file

@ -260,6 +260,11 @@ class HaproxyConfigGenerator:
# Extract all plugin configs in a single loop
plugin_configs_for_host = []
for result in domain_results:
# Allow plugins to override host-level config (e.g. proto)
if result.modified_easymapping:
for key, value in result.modified_easymapping.items():
easymapping[port]["hosts"][hostname][key] = value
# HAProxy config snippets for this domain
if result.haproxy_config:
plugin_configs_for_host.append(result.haproxy_config)

View file

@ -4,7 +4,7 @@ import shutil
import subprocess
import sys
import time
from multiprocessing import Process
import multiprocessing
from typing import Final
import psutil
@ -31,7 +31,7 @@ class DaemonizeHAProxy:
logger_haproxy.fatal(f"Failed to start HAProxy ({action}). Exiting.")
sys.exit(1)
self.thread = Process(target=self.__start, args=())
self.thread = multiprocessing.get_context('fork').Process(target=self.__start, args=())
self.thread.start()
@staticmethod

View file

@ -148,7 +148,7 @@ class FastcgiPlugin(PluginInterface):
return PluginResult(
haproxy_config=backend_config, # use-fcgi-app directive for the backend
modified_easymapping=None,
modified_easymapping={"proto": "fcgi"},
metadata=metadata,
global_configs=[fcgi_app_definition] # For top-level injection
)

View file

@ -269,6 +269,7 @@ class Kubernetes(ProcessorInterface):
redirect_ssl = self._check_annotation(annotations, "easyhaproxy.redirect_ssl")
redirect = self._check_annotation(annotations, "easyhaproxy.redirect")
mode = self._check_annotation(annotations, "easyhaproxy.mode")
proto = self._check_annotation(annotations, "easyhaproxy.proto")
listen_port = self._check_annotation(annotations, "easyhaproxy.listen_port", 80)
plugins = self._check_annotation(annotations, "easyhaproxy.plugins")
@ -432,6 +433,8 @@ class Kubernetes(ProcessorInterface):
rule_data[f"{definition}.redirect"] = redirect
if mode is not None:
rule_data[f"{definition}.mode"] = mode
if proto is not None:
rule_data[f"{definition}.proto"] = proto
rule_data[f"{definition}.balance"] = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.balance", "roundrobin")
# Add plugin configuration