Skip to content

Commit 6fc80eb

Browse files
JamBalaya56562claude
authored andcommitted
feat: IPv6 support for standalone challenge config (#1267)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cc0c8bb commit 6fc80eb

6 files changed

Lines changed: 76 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ jobs:
118118
- test-name: debug_acmesh_log
119119
setup: 2containers
120120
pebble-config: pebble-config.json
121+
- test-name: standalone_ipv6
122+
setup: 2containers
123+
pebble-config: pebble-config.json
121124
runs-on: ubuntu-latest
122125

123126
steps:

app/functions.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,14 @@ function add_standalone_configuration {
135135
add_location_configuration "$domain"
136136
else
137137
# Else use the standalone configuration.
138+
local listen_directives=' listen 80;'
139+
if parse_true "${ENABLE_IPV6:-false}"; then
140+
listen_directives+=$'\n listen [::]:80;'
141+
fi
138142
cat > "/etc/nginx/conf.d/standalone-cert-$domain.conf" << EOF
139143
server {
140144
server_name $domain;
141-
listen 80;
145+
${listen_directives}
142146
access_log /var/log/nginx/access.log vhost;
143147
location ^~ /.well-known/acme-challenge/ {
144148
auth_basic off;

docs/Container-configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ You can also create test certificates per container (see [Test certificates](./L
4040

4141
* `ACME_HTTP_CHALLENGE_LOCATION` - Previously **acme-companion** automatically added the ACME HTTP challenge location to the nginx configuration through files generated in `/etc/nginx/vhost.d`. Recent versions of **nginx-proxy** (>= `1.6`) already include the required location configuration, which remove the need for **acme-companion** to attempt to dynamically add them. If you're running and older version of **nginx-proxy** (or **docker-gen** with an older version of the `nginx.tmpl` file), you can re-enable this behaviour by setting `ACME_HTTP_CHALLENGE_LOCATION` to `true`.
4242

43+
* `ENABLE_IPV6` - Set it to `true` to make the **standalone** ACME HTTP challenge configuration (used for domains not served by **nginx-proxy**, e.g. `LETSENCRYPT_STANDALONE_CERTS`) also listen over IPv6 (`listen [::]:80;`) in addition to IPv4. This matches **nginx-proxy**'s [`ENABLE_IPV6`](https://github.com/nginx-proxy/nginx-proxy#ipv6-support) option, so set the same value on both containers. Leave it unset (or `false`) unless your host and its Docker networking actually support IPv6, otherwise nginx may fail to bind the IPv6 socket. Only the standalone challenge config is affected; challenges served through nginx-proxy already follow nginx-proxy's own IPv6 setting.
44+
4345
* `RELOAD_NGINX_ONLY_ONCE` - The companion reload nginx configuration after every new or renewed certificate. Previously this was done only once per service loop, at the end of the loop (this was causing delayed availability of HTTPS enabled application when multiple new certificates where requested at once, see [issue #1147](https://github.com/nginx-proxy/acme-companion/issues/1147)). You can restore the previous behaviour if needed by setting the environment variable `RELOAD_NGINX_ONLY_ONCE` to `true`.
4446

4547
* `DOCKER_CONTAINER_FILTERS` - You can filter which containers are considered by acme-companion by using the `DOCKER_CONTAINER_FILTERS` environment variable (by default, acme-companion will consider all running containers). It takes a comma separated list of `key=value` pairs. For example, setting `DOCKER_CONTAINER_FILTERS` environment variable to `network=mynetwork` will cause acme-companion to consider only containers connected to the `mynetwork` network. See the [Docker CLI documentation](https://docs.docker.com/reference/cli/docker/container/ls/#filter) for details on available filters.

test/config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ globalTests+=(
1010
certs_san
1111
certs_single_domain
1212
certs_standalone
13+
standalone_ipv6
1314
force_renew
1415
acme_accounts
1516
private_keys
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## ipv6-enabled
2+
server {
3+
server_name ipv6.example.test;
4+
listen 80;
5+
listen [::]:80;
6+
access_log /var/log/nginx/access.log vhost;
7+
location ^~ /.well-known/acme-challenge/ {
8+
auth_basic off;
9+
auth_request off;
10+
allow all;
11+
root /usr/share/nginx/html;
12+
try_files $uri =404;
13+
break;
14+
}
15+
}
16+
## ipv6-disabled
17+
server {
18+
server_name plain.example.test;
19+
listen 80;
20+
access_log /var/log/nginx/access.log vhost;
21+
location ^~ /.well-known/acme-challenge/ {
22+
auth_basic off;
23+
auth_request off;
24+
allow all;
25+
root /usr/share/nginx/html;
26+
try_files $uri =404;
27+
break;
28+
}
29+
}
30+
## ipv6-unset
31+
server {
32+
server_name unset.example.test;
33+
listen 80;
34+
access_log /var/log/nginx/access.log vhost;
35+
location ^~ /.well-known/acme-challenge/ {
36+
auth_basic off;
37+
auth_request off;
38+
allow all;
39+
root /usr/share/nginx/html;
40+
try_files $uri =404;
41+
break;
42+
}
43+
}

test/tests/standalone_ipv6/run.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
## Test that standalone challenge configs listen over IPv6 only when ENABLE_IPV6 is set. See #710.
4+
5+
commands="$(cat <<'EOF'
6+
source /app/functions.sh
7+
mkdir -p /etc/nginx/conf.d
8+
printf 'server { server_name other.example.test; }\n' > /etc/nginx/conf.d/other.conf
9+
10+
echo '## ipv6-enabled'
11+
( export ENABLE_IPV6=true; add_standalone_configuration 'ipv6.example.test' )
12+
cat /etc/nginx/conf.d/standalone-cert-ipv6.example.test.conf
13+
echo '## ipv6-disabled'
14+
( export ENABLE_IPV6=false; add_standalone_configuration 'plain.example.test' )
15+
cat /etc/nginx/conf.d/standalone-cert-plain.example.test.conf
16+
echo '## ipv6-unset'
17+
( unset ENABLE_IPV6; add_standalone_configuration 'unset.example.test' )
18+
cat /etc/nginx/conf.d/standalone-cert-unset.example.test.conf
19+
EOF
20+
)"
21+
22+
docker run --rm "$1" bash -c "$commands" 2>&1

0 commit comments

Comments
 (0)