Skip to content

Commit 310beb4

Browse files
committed
Add support for HTTP2 in HAProxy frontend and listen sections
This commit introduces the `http2` boolean field for enabling HTTP2 support in HTTPS schemes. Updates were made to both backend logic and documentation for `frontend` and `listen` resources to reflect this new functionality. These changes enhance compatibility with modern web traffic protocols.
1 parent f5266e9 commit 310beb4

7 files changed

+23
-0
lines changed

docs/resources/haproxy_section_frontend.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ resource "roxywi_haproxy_section_frontend" "example" {
6969
- `slow_attack` (Boolean) In a Slow POST attack, an attacker begins by sending a legitimate HTTP POST header to a Web server, exactly as they would under normal circumstances. The header specifies the exact size of the message body that will then follow. However, that message body is then sent at an alarmingly low rate – sometimes as slow as 1 byte per approximately two minutes.
7070
- `ssl` (Block Set) SSL settings. (see [below for nested schema](#nestedblock--ssl))
7171
- `ssl_offloading` (Boolean) Enable redirection from HTTP scheme to HTTPS scheme.
72+
- `http2` (Boolean) Enable HTTP2 for HTTPS scheme.
7273
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
7374
- `waf` (Boolean) Add WAF settings.
7475
- `whitelist` (String) Path to a whitelist.

docs/resources/haproxy_section_listen.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ resource "roxywi_haproxy_section_listen" "example" {
7676
- `slow_attack` (Boolean) In a Slow POST attack, an attacker begins by sending a legitimate HTTP POST header to a Web server, exactly as they would under normal circumstances. The header specifies the exact size of the message body that will then follow. However, that message body is then sent at an alarmingly low rate – sometimes as slow as 1 byte per approximately two minutes.
7777
- `ssl` (Block Set) SSL settings. (see [below for nested schema](#nestedblock--ssl))
7878
- `ssl_offloading` (Boolean) Enable redirection from HTTP scheme to HTTPS scheme.
79+
- `http2` (Boolean) Enable HTTP2 for HTTPS scheme.
7980
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
8081
- `waf` (Boolean) Add WAF settings.
8182
- `whitelist` (String) Path to a whitelist.

roxywi/haproxy_section_fields.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const (
5656
SslCertField = "cert"
5757
SslCheckField = "ssl_check_backend"
5858
SslOffloadingField = "ssl_offloading"
59+
Http2Field = "http2"
5960
RedisPatchField = "redispatch"
6061
RoundRobinAlgorithm = "roundrobin"
6162
SourceAlgorithm = "source"

roxywi/resource_roxywi_haproxy_section_frontend.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ func resourceHaproxySectionFrontend() *schema.Resource {
126126
Default: false,
127127
Description: "Enable redirection from HTTP scheme to HTTPS scheme.",
128128
},
129+
Http2Field: {
130+
Type: schema.TypeBool,
131+
Optional: true,
132+
Default: false,
133+
Description: "Enable HTTP2 for HTTPS scheme.",
134+
},
129135
CompressionField: {
130136
Type: schema.TypeBool,
131137
Optional: true,
@@ -198,6 +204,7 @@ func resourceHaproxySectionFrontendCreate(ctx context.Context, d *schema.Resourc
198204
CompressionField: d.Get(CompressionField),
199205
ForwardForField: d.Get(ForwardForField),
200206
SslOffloadingField: d.Get(SslOffloadingField),
207+
Http2Field: d.Get(Http2Field),
201208
SlowAttackField: d.Get(SlowAttackField),
202209
AntiBotField: d.Get(AntiBotField),
203210
DdosField: d.Get(DdosField),
@@ -251,6 +258,7 @@ func resourceHaproxySectionFrontendRead(ctx context.Context, d *schema.ResourceD
251258
d.Set(CompressionField, result[CompressionField])
252259
d.Set(ForwardForField, result[ForwardForField])
253260
d.Set(SslOffloadingField, result[SslOffloadingField])
261+
d.Set(Http2Field, result[Http2Field])
254262
d.Set(SlowAttackField, result[SlowAttackField])
255263
d.Set(AntiBotField, result[AntiBotField])
256264
d.Set(DdosField, result[DdosField])
@@ -315,6 +323,7 @@ func resourceHaproxySectionFrontendUpdate(ctx context.Context, d *schema.Resourc
315323
CompressionField: d.Get(CompressionField),
316324
ForwardForField: d.Get(ForwardForField),
317325
SslOffloadingField: d.Get(SslOffloadingField),
326+
Http2Field: d.Get(Http2Field),
318327
SlowAttackField: d.Get(SlowAttackField),
319328
AntiBotField: d.Get(AntiBotField),
320329
DdosField: d.Get(DdosField),

roxywi/resource_roxywi_haproxy_section_listen.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ func resourceHaproxySectionListen() *schema.Resource {
152152
Default: false,
153153
Description: "Enable redirection from HTTP scheme to HTTPS scheme.",
154154
},
155+
Http2Field: {
156+
Type: schema.TypeBool,
157+
Optional: true,
158+
Default: false,
159+
Description: "Enable HTTP2 for HTTPS scheme.",
160+
},
155161
RedisPatchField: {
156162
Type: schema.TypeBool,
157163
Optional: true,
@@ -285,6 +291,7 @@ func resourceHaproxySectionListenCreate(ctx context.Context, d *schema.ResourceD
285291
CompressionField: d.Get(CompressionField),
286292
ForwardForField: d.Get(ForwardForField),
287293
SslOffloadingField: d.Get(SslOffloadingField),
294+
Http2Field: d.Get(Http2Field),
288295
SlowAttackField: d.Get(SlowAttackField),
289296
AntiBotField: d.Get(AntiBotField),
290297
DdosField: d.Get(DdosField),
@@ -338,6 +345,7 @@ func resourceHaproxySectionListenRead(ctx context.Context, d *schema.ResourceDat
338345
d.Set(CompressionField, result[CompressionField])
339346
d.Set(ForwardForField, result[ForwardForField])
340347
d.Set(SslOffloadingField, result[SslOffloadingField])
348+
d.Set(Http2Field, result[Http2Field])
341349
d.Set(SlowAttackField, result[SlowAttackField])
342350
d.Set(AntiBotField, result[AntiBotField])
343351
d.Set(DdosField, result[DdosField])
@@ -447,6 +455,7 @@ func resourceHaproxySectionListenUpdate(ctx context.Context, d *schema.ResourceD
447455
CompressionField: d.Get(CompressionField),
448456
ForwardForField: d.Get(ForwardForField),
449457
SslOffloadingField: d.Get(SslOffloadingField),
458+
Http2Field: d.Get(Http2Field),
450459
SlowAttackField: d.Get(SlowAttackField),
451460
AntiBotField: d.Get(AntiBotField),
452461
DdosField: d.Get(DdosField),

templates/resources/haproxy_section_frontend.md.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Manage HAProxy Frontend sections. Please note that changes may cause HAProxy to
4040
- `slow_attack` (Boolean) In a Slow POST attack, an attacker begins by sending a legitimate HTTP POST header to a Web server, exactly as they would under normal circumstances. The header specifies the exact size of the message body that will then follow. However, that message body is then sent at an alarmingly low rate – sometimes as slow as 1 byte per approximately two minutes.
4141
- `ssl` (Block Set) SSL settings. (see [below for nested schema](#nestedblock--ssl))
4242
- `ssl_offloading` (Boolean) Enable redirection from HTTP scheme to HTTPS scheme.
43+
- `http2` (Boolean) Enable HTTP2 for HTTPS scheme.
4344
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
4445
- `waf` (Boolean) Add WAF settings.
4546
- `whitelist` (String) Path to a whitelist.

templates/resources/haproxy_section_listen.md.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Manage HAProxy Listen sections. Please note that changes may cause HAProxy to re
4949
- `slow_attack` (Boolean) In a Slow POST attack, an attacker begins by sending a legitimate HTTP POST header to a Web server, exactly as they would under normal circumstances. The header specifies the exact size of the message body that will then follow. However, that message body is then sent at an alarmingly low rate – sometimes as slow as 1 byte per approximately two minutes.
5050
- `ssl` (Block Set) SSL settings. (see [below for nested schema](#nestedblock--ssl))
5151
- `ssl_offloading` (Boolean) Enable redirection from HTTP scheme to HTTPS scheme.
52+
- `http2` (Boolean) Enable HTTP2 for HTTPS scheme.
5253
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
5354
- `waf` (Boolean) Add WAF settings.
5455
- `whitelist` (String) Path to a whitelist.

0 commit comments

Comments
 (0)