@@ -151,7 +151,7 @@ def _on_haproxy_route_data_available(self, event: EventBase) -> None:
151151
152152# Increment this PATCH version before using `charmcraft publish-lib` or reset
153153# to 0 if you are raising the major API version
154- LIBPATCH = 8
154+ LIBPATCH = 9
155155
156156logger = logging .getLogger (__name__ )
157157HAPROXY_ROUTE_RELATION_NAME = "haproxy-route"
@@ -538,6 +538,8 @@ class RequirerApplicationData(_DatabagModel):
538538 timeout: Configuration for server, client, and queue timeouts.
539539 server_maxconn: Optional maximum number of connections per server.
540540 http_server_close: Configure server close after request.
541+ allow_http: Whether to allow HTTP traffic in addition to HTTPS. Defaults to False.
542+ Warning: enabling HTTP is a security risk, make sure you apply the necessary precautions.
541543 """
542544
543545 service : VALIDSTR = Field (description = "The name of the service." )
@@ -589,6 +591,9 @@ class RequirerApplicationData(_DatabagModel):
589591 http_server_close : bool = Field (
590592 description = "Configure server close after request" , default = False
591593 )
594+ allow_http : bool = Field (
595+ description = "Whether to allow HTTP traffic in addition to HTTPS." , default = False
596+ )
592597
593598 @field_validator ("load_balancing" )
594599 @classmethod
@@ -945,6 +950,7 @@ def __init__(
945950 server_maxconn : Optional [int ] = None ,
946951 unit_address : Optional [str ] = None ,
947952 http_server_close : bool = False ,
953+ allow_http : bool = False ,
948954 ) -> None :
949955 """Initialize the HaproxyRouteRequirer.
950956
@@ -983,6 +989,9 @@ def __init__(
983989 server_maxconn: Maximum connections per server.
984990 unit_address: IP address of the unit (if not provided, will use binding address).
985991 http_server_close: Configure server close after request.
992+ allow_http: Whether to allow HTTP traffic in addition to HTTPS.
993+ Warning: enabling HTTP is a security risk,
994+ make sure you apply the necessary precautions.
986995 """
987996 super ().__init__ (charm , relation_name )
988997
@@ -1023,6 +1032,7 @@ def __init__(
10231032 queue_timeout ,
10241033 server_maxconn ,
10251034 http_server_close ,
1035+ allow_http ,
10261036 )
10271037 self ._unit_address = unit_address
10281038
@@ -1079,6 +1089,7 @@ def provide_haproxy_route_requirements(
10791089 server_maxconn : Optional [int ] = None ,
10801090 unit_address : Optional [str ] = None ,
10811091 http_server_close : bool = False ,
1092+ allow_http : bool = False ,
10821093 ) -> None :
10831094 """Update haproxy-route requirements data in the relation.
10841095
@@ -1115,6 +1126,9 @@ def provide_haproxy_route_requirements(
11151126 server_maxconn: Maximum connections per server.
11161127 unit_address: IP address of the unit (if not provided, will use binding address).
11171128 http_server_close: Configure server close after request.
1129+ allow_http: Whether to allow HTTP traffic in addition to HTTPS.
1130+ Warning: enabling HTTP is a security risk,
1131+ make sure you apply the necessary precautions.
11181132 """
11191133 self ._unit_address = unit_address
11201134 self ._application_data = self ._generate_application_data (
@@ -1148,6 +1162,7 @@ def provide_haproxy_route_requirements(
11481162 queue_timeout ,
11491163 server_maxconn ,
11501164 http_server_close ,
1165+ allow_http ,
11511166 )
11521167 self .update_relation_data ()
11531168
@@ -1184,6 +1199,7 @@ def _generate_application_data( # noqa: C901
11841199 queue_timeout : int = 60 ,
11851200 server_maxconn : Optional [int ] = None ,
11861201 http_server_close : bool = False ,
1202+ allow_http : bool = False ,
11871203 ) -> dict [str , Any ]:
11881204 """Generate the complete application data structure.
11891205
@@ -1219,6 +1235,9 @@ def _generate_application_data( # noqa: C901
12191235 queue_timeout: Timeout for requests waiting in queue in seconds.
12201236 server_maxconn: Maximum connections per server.
12211237 http_server_close: Configure server close after request.
1238+ allow_http: Whether to allow HTTP traffic in addition to HTTPS.
1239+ Warning: enabling HTTP is a security risk,
1240+ make sure you apply the necessary precautions.
12221241
12231242 Returns:
12241243 dict: A dictionary containing the complete application data structure.
@@ -1271,8 +1290,15 @@ def _generate_application_data( # noqa: C901
12711290 header_rewrite_expressions ,
12721291 ),
12731292 "http_server_close" : http_server_close ,
1293+ "allow_http" : allow_http ,
12741294 }
12751295
1296+ if allow_http :
1297+ logger .warning (
1298+ "HTTP traffic is allowed alongside HTTPS. "
1299+ "This is a security risk, make sure you apply the necessary precautions."
1300+ )
1301+
12761302 if check := self ._generate_server_healthcheck_configuration (
12771303 check_interval , check_rise , check_fall , check_path , check_port
12781304 ):
0 commit comments