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

conditionally enable ipv6 listen directives in nginx configs #20880

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ services:
{% endif %}
networks:
- harbor
{% if ip_family.ipv6.enabled %}
- harbor_ipv6
{% endif %}
ports:
- {{http_port}}:8080
{% if protocol == 'https' %}
Expand Down Expand Up @@ -399,4 +402,8 @@ services:
networks:
harbor:
external: false

{% if ip_family.ipv6.enabled %}
harbor_ipv6:
external: false
enable_ipv6: true
{% endif %}
10 changes: 10 additions & 0 deletions make/photon/prepare/templates/nginx/nginx.http.conf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ http {
}

server {
{% if ip_family.ipv4.enabled %}
listen 8080;
{% endif %}
{% if ip_family.ipv6.enabled %}
listen [::]:8080;
{% endif %}
server_tokens off;
# disable any limits to avoid HTTP 413 for large image uploads
client_max_body_size 0;
Expand Down Expand Up @@ -200,7 +205,12 @@ http {
}

server {
{% if ip_family.ipv4.enabled %}
listen 9090;
{% endif %}
{% if ip_family.ipv6.enabled %}
listen [::]:9090;
{% endif %}
location = /metrics {
if ($arg_comp = core) { proxy_pass http://core_metrics; }
if ($arg_comp = jobservice) { proxy_pass http://js_metrics; }
Expand Down
10 changes: 10 additions & 0 deletions make/photon/prepare/templates/nginx/nginx.https.conf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ http {
}
}
server {
{% if ip_family.ipv4.enabled %}
listen 8080;
{% endif %}
{% if ip_family.ipv6.enabled %}
listen [::]:8080;
{% endif %}
#server_name harbordomain.com;
return 308 https://{{https_redirect}}$request_uri;
}
Expand All @@ -236,7 +241,12 @@ http {
}

server {
{% if ip_family.ipv4.enabled %}
listen 9090;
{% endif %}
{% if ip_family.ipv6.enabled %}
listen [::]:9090;
{% endif %}
location = {{ metric.path }} {
if ($arg_comp = core) { proxy_pass http://core_metrics; }
if ($arg_comp = jobservice) { proxy_pass http://js_metrics; }
Expand Down
5 changes: 5 additions & 0 deletions make/photon/prepare/templates/portal/nginx.conf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ http {
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
{% else %}
{% if ip_family.ipv4.enabled %}
listen 8080;
{% endif %}
{% if ip_family.ipv6.enabled %}
listen [::]:8080;
{% endif %}
{% endif %}
server_name localhost;

Expand Down
1 change: 1 addition & 0 deletions make/photon/prepare/utils/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def prepare_docker_compose(configs, with_trivy):
'http_port': configs['http_port'],
'external_redis': configs['external_redis'],
'external_database': configs['external_database'],
'ip_family': configs['ip_family'],
'with_trivy': with_trivy,
}

Expand Down
3 changes: 2 additions & 1 deletion make/photon/prepare/utils/nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def render_nginx_template(config_dict):
uid=DEFAULT_UID,
gid=DEFAULT_GID,
internal_tls=config_dict['internal_tls'],
metric=config_dict['metric'])
metric=config_dict['metric'],
ip_family=config_dict['ip_family'])
location_file_pattern = CUSTOM_NGINX_LOCATION_FILE_PATTERN_HTTP
copy_nginx_location_configs_if_exist(nginx_template_ext_dir, nginx_confd_dir, location_file_pattern)

Expand Down