Skip to content

Commit

Permalink
Add feature flags for IPv6
Browse files Browse the repository at this point in the history
Signed-off-by: Dave O'Connor <doconnor@redhat.com>
  • Loading branch information
HammerMeetNail committed Sep 9, 2022
1 parent e566560 commit d923660
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions conf/init/nginx_conf_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def generate_nginx_config(config):
enable_rate_limits = config.get("FEATURE_RATE_LIMITS", False)
ssl_protocols = config.get("SSL_PROTOCOLS", SSL_PROTOCOL_DEFAULTS)
ssl_ciphers = config.get("SSL_CIPHERS", SSL_CIPHER_DEFAULTS)

# Enable IPv4 and/or IPv6. Valid values are IPv4, IPv6 or dual-stack.
ip_version = config.get("FEATURE_LISTEN_IP_VERSION", "IPv4")
use_ipv4 = True if ip_version.lower() != "ipv6" else False
use_ipv6 = True if ip_version.lower() in ["ipv6", "dual-stack"] else False

write_config(
os.path.join(QUAYCONF_DIR, "nginx/nginx.conf"),
Expand All @@ -82,6 +87,8 @@ def generate_nginx_config(config):
v1_only_domain=v1_only_domain,
ssl_protocols=ssl_protocols,
ssl_ciphers=":".join(ssl_ciphers),
use_ipv4=use_ipv4,
use_ipv6=use_ipv6,
)


Expand Down
24 changes: 24 additions & 0 deletions conf/nginx/nginx.conf.jnj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ http {

include server-base.conf;

{% if use_ipv4 %}
listen 8443 ssl http2 default;
{% endif %}
{% if use_ipv6 %}
listen [::]:8443 ssl http2 default;
{% endif %}

ssl on;

Expand All @@ -57,8 +61,12 @@ http {

include server-base.conf;

{% if use_ipv4 %}
listen 7443 ssl http2 default proxy_protocol;
{% endif %}
{% if use_ipv6 %}
listen [::]:7443 ssl http2 default proxy_protocol;
{% endif %}

ssl on;

Expand All @@ -80,8 +88,12 @@ http {
ssl_certificate ../stack/ssl.cert;
ssl_certificate_key ../stack/ssl.key;

{% if use_ipv4 %}
listen 55443 ssl http2 default;
{% endif %}
{% if use_ipv6 %}
listen [::]:55443 ssl http2 default;
{% endif %}
ssl on;

# Required for gRPC streaming of long running builds
Expand Down Expand Up @@ -114,8 +126,12 @@ http {
ssl_certificate ../stack/ssl.cert;
ssl_certificate_key ../stack/ssl.key;

{% if use_ipv4 %}
listen 8443 ssl;
{% endif %}
{% if use_ipv6 %}
listen [::]:8443 ssl;
{% endif %}

ssl on;

Expand All @@ -133,8 +149,12 @@ http {

include server-base.conf;

{% if use_ipv4 %}
listen 7443 ssl proxy_protocol;
{% endif %}
{% if use_ipv6 %}
listen [::]:7443 ssl proxy_protocol;
{% endif %}
ssl on;

# This header must be set only for HTTPS
Expand All @@ -159,8 +179,12 @@ http {
server {
include server-base.conf;

{% if use_ipv4 %}
listen 8080 default;
{% endif %}
{% if use_ipv6 %}
listen [::]:8080 default;
{% endif %}

access_log /var/log/nginx/access.log lb_logs;
}
Expand Down
5 changes: 5 additions & 0 deletions util/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,5 +1247,10 @@
"description": "Cross-Origin domain to allow requests from",
"x-example": "localhost:9000",
},
"FEATURE_LISTEN_IP_VERSION": {
"type": "string",
"description": "Enables IPv4, IPv6 or dual-stack networking. Defaults to `IPv4`.",
"x-example": "IPv4",
},
},
}

0 comments on commit d923660

Please sign in to comment.