Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPv3 and QUIC related changes #353

Merged
merged 18 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
\#*
!molecule.crt
!molecule.key
!rand.key

# OS Specific #
###############
Expand Down
13 changes: 13 additions & 0 deletions defaults/main/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ nginx_config_main_template:
- /etc/nginx/conf.d/*.conf
# stream:
# include: /etc/nginx/conf.d/stream/*.conf # String or a list of strings
# quic:
# bpf: false # Boolean
oxpa marked this conversation as resolved.
Show resolved Hide resolved

# Enable creating dynamic templated NGINX HTTP configuration files.
# Defaults will not produce a valid configuration. Instead they are meant to showcase
Expand Down Expand Up @@ -204,6 +206,7 @@ nginx_config_http_template:
port: 80
default_server: true # Boolean
ssl: false # Boolean
quic: false # Boolean
proxy_protocol: false # Boolean
fastopen: 12 # Number
backlog: 511 # Number
Expand Down Expand Up @@ -278,6 +281,16 @@ nginx_config_http_template:
max_concurrent_streams: 128 # Number -- Not available in the 'location' context
recv_buffer_size: 256k # Only available in the 'http' context
recv_timeout: 20s # Not available in the 'location' context
http3:
enable: false # Boolean
hq: false # Boolean
oxpa marked this conversation as resolved.
Show resolved Hide resolved
max_concurrent_streams: 128
oxpa marked this conversation as resolved.
Show resolved Hide resolved
stream_buffer_size: 64k
quic:
active_connection_id_limit: 2
gso: false # Boolean
oxpa marked this conversation as resolved.
Show resolved Hide resolved
host_key: /path/to/file
retry: false # Boolean
oxpa marked this conversation as resolved.
Show resolved Hide resolved
ssl: # Configure SSL
buffer_size: 16k
certificate: /path/to/file # String or a list of strings
Expand Down
1 change: 1 addition & 0 deletions molecule/common/files/ssl/rand.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EÇ4úh¹’¶4ãÖšYýâ &i"/mÑ{÷7±®<%…J%f·ÿê^Ñì`R¿PÃÐ[ Ä,6=!ª>Zå »oéKÎcGè
21 changes: 21 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
- src: ../common/files/ssl/molecule.key
dest: /etc/ssl/private
backup: true
- src: ../common/files/ssl/rand.key
dest: /etc/ssl/private
backup: true

nginx_config_main_template_enable: true
nginx_config_main_template:
Expand Down Expand Up @@ -67,6 +70,8 @@
threads: 32
timer_resolution: 1s
working_directory: /etc/nginx
quic:
bpf: false
events:
accept_mutex: false
accept_mutex_delay: 500ms
Expand Down Expand Up @@ -236,6 +241,11 @@
max_concurrent_streams: 31
recv_buffer_size: 128k
recv_timeout: 10s
http3:
enable: true
hq: false
max_concurrent_streams: 100
stream_buffer_size: 32k
ssl:
buffer_size: 16k
certificate: /etc/ssl/certs/molecule.crt
Expand All @@ -257,6 +267,7 @@
- TLSv1
- TLSv1.1
- TLSv1.2
- TLSv1.3
reject_handshake: false
session_cache:
builtin:
Expand Down Expand Up @@ -569,6 +580,8 @@
port: 443
default_server: true
ssl: false
quic: true
reuseport: true
so_keepalive:
keepidle: 30m
keepintvl: 5
Expand All @@ -585,6 +598,14 @@
http2:
enable: false
chunk_size: 8k
http3:
enabled: false
hq: true
quic:
active_connection_id_limit: 10
gso: false
retry: false
host_key: /etc/ssl/private/rand.key
auth_basic:
realm: false
log:
Expand Down
3 changes: 3 additions & 0 deletions molecule/push/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
- src: ../common/files/ssl/molecule.key
dest: /etc/ssl/private
backup: true
- src: ../common/files/ssl/rand.key
dest: /etc/ssl/private
backup: true
3 changes: 3 additions & 0 deletions templates/core.j2
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ timer_resolution {{ main['timer_resolution'] }};
{% if main['working_directory'] is defined %}
working_directory {{ main['working_directory'] }};
{% endif %}
{% if main['quic'] is defined and main['quic']['bpf'] is defined and main['quic']['bpf'] is boolean %}
Copy link
Collaborator

@alessfg alessfg Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% if main['quic'] is defined and main['quic']['bpf'] is defined and main['quic']['bpf'] is boolean %}
{% if main['quic']['bpf'] is defined and main['quic']['bpf'] is boolean %}{# ngx_http_quic_module #}{# This does not belong here but we are making an exception #}

We can simplify this a little bit I think

quic_bpf {{ main['quic']['bpf'] | ternary('on', 'off') }};
{% endif %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As convenient as it is, this really should be included in the http3/quic template. Directives in this template belong exclusively to the ngx_core_module.

Instead, I would tweak the nginx.conf.j2 template to something along the lines of

{% if nginx_config_main_template['config']['main'] is defined %}
{% from 'core.j2' import main with context %}
{{ main(nginx_config_main_template['config']['main']) }}
{%- endif %}
{% if nginx_config_main_template['config']['main']['quic'] is defined %}
{% from 'http/modules.j2' import main with context %}
...
{%- endif %}

And we can then use scopes (!) to make sure that only the quic_bpf parameter/directive can be used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, IMO, bpf settings should be moved to core module in nginx as well. But I get the point. I'll move it out.

{% endmacro %}

{% macro events(events) %}
Expand Down
1 change: 1 addition & 0 deletions templates/http/core.j2
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ lingering_timeout {{ core['lingering_timeout'] }};
listen {{ listen['address'] if listen['address'] is defined }}{{ ':' if listen['address'] is defined and listen['port'] is defined }}{{ listen['port'] if listen['port'] is defined -}}
{{- ' default_server' if listen['default_server'] is defined and listen['default_server'] is boolean and listen['default_server'] | bool -}}
{{- ' ssl' if listen['ssl'] is defined and listen['ssl'] is boolean and listen['ssl'] | bool -}}
{{- ' quic' if listen['quic'] is defined and listen['quic'] is boolean and listen['quic'] | bool -}}
{{- ' proxy_protocol' if listen['proxy_protocol'] is defined and listen['proxy_protocol'] is boolean and listen['proxy_protocol'] | bool -}}
{{- (' setfib=' + listen['setfib'] | string) if listen['setfib'] is defined -}}
{{- (' fastopen=' + listen['fastopen'] | string) if listen['fastopen'] is defined and listen['fastopen'] is number -}}
Expand Down
21 changes: 21 additions & 0 deletions templates/http/default.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
{% from 'http/modules.j2' import http2 with context %}
{{ http2(item['config']['http2'], 'http') }}
{%- endif %}
{% if item['config']['http3'] is defined %}
{% from 'http/modules.j2' import http3 with context %}
{{ http3(item['config']['http3']) }}
{%- endif %}
{% if item['config']['quic'] is defined %}
{% from 'http/modules.j2' import quic with context %}
{{ quic(item['config']['quic']) }}
{%- endif %}
{% if item['config']['ssl'] is defined %}
{% from 'http/ssl.j2' import ssl with context %}
{{ ssl(item['config']['ssl']) }}
Expand Down Expand Up @@ -134,6 +142,19 @@ server {
{{ http2(server['http2'], 'server') }}
{%- endfilter %}
{% endif %}
{% if server['http3'] is defined %}
{% from 'http/modules.j2' import http3 with context %}
{% filter indent(4) %}
{{ http3(server['http3']) }}
{%- endfilter %}
{% endif %}
{% if server['quic'] is defined %}
{% from 'http/modules.j2' import quic with context %}
{% filter indent(4) %}
{{ quic(server['quic']) }}
{%- endfilter %}
{% endif %}

{% if server['ssl'] is defined %}
{% from 'http/ssl.j2' import ssl with context %}
{% filter indent(4) %}
Expand Down
33 changes: 33 additions & 0 deletions templates/http/modules.j2
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,36 @@ http2_chunk_size {{ http2['chunk_size'] }};
{% endif %}

{% endmacro %}
oxpa marked this conversation as resolved.
Show resolved Hide resolved

{# NGINX HTTP v3 -- ngx_http_v3_module #}
{% macro http3(http3) %}
{% if http3['enabled'] is defined and http3['enabled'] is boolean %}
http3 {{ http3['enabled'] | ternary('on', 'off') }};
{% endif %}
{% if http3['hq'] is defined and http3['hq'] is boolean %}
http3_hq {{ http3['hq'] | ternary('on', 'off') }};
{% endif %}
{% if http3['max_concurrent_streams'] is defined and http3['max_concurrent_streams'] is number %}
http3_max_concurrent_streams {{ http3['max_concurrent_streams'] }};
{% endif %}
{% if http3['stream_buffer_size'] is defined %}
http3_stream_buffer_size {{ http3['stream_buffer_size'] }};
{% endif %}

{% endmacro %}

{# NGINX QUIC -- ngix_http_v3_module #}
Copy link
Collaborator

@alessfg alessfg Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{# NGINX QUIC -- ngix_http_v3_module #}
{# NGINX QUIC -- ngx_http_quic_module #}{# This module is not "documented" but it does exist internally #}

{% macro quic(quic) %}
{% if quic['active_connection_id_limit'] is defined and quic['active_connection_id_limit'] is number %}
quic_active_connection_id_limit {{ quic['active_connection_id_limit'] }};
{% endif %}
{% if quic['gso'] is defined and quic['gso'] is boolean %}
quic_gso {{ quic['gso'] | ternary('on','off') }};
{% endif %}
{% if quic['host_key'] is defined %}
quic_host_key {{ quic['host_key'] }};
{% endif %}
{% if quic['retry'] is defined and quic['retry'] is boolean %}
quic_retry {{ quic['retry'] | ternary('on','off') }};
{% endif %}
oxpa marked this conversation as resolved.
Show resolved Hide resolved
{% endmacro %}
Loading