IPv6 and nginx running in container on Docker for Mac

Hi,

I am a newbie running tusd server on macos High Sierra behind an Nginx Proxy running within a docker container. In the logs, I notice that before an UploadCreated event is received there is an attempt to connect to tusd using ipv6 loopback address which fails.

[crit] 23#23: *4 connect() to [::1]:1080 failed (99: Address not available) while connecting to upstream, client: 172.22.0.1, server: , request: “POST /files/ HTTP/1.1”, upstream: “http://[::1]:1080/files/”, host: “test.example.com:1081

I am using an nginx configuration listed below:

server {
  listen                          1081 ssl http2;
  #listen [::]:443 http2 ipv6only=on ssl;
  charset                         utf-8;

  access_log                      /dev/stdout;
  error_log                       /dev/stdout;

  ssl_certificate                 /server/certs/tls.crt;
  ssl_certificate_key             /server/certs/tls.key;

  location /files/ {

    resolver 8.8.8.8 4.2.2.2;
    #resolver 8.8.8.8 4.2.2.2 ipv6only=off;

    proxy_pass  http://localhost:1080/files/;
    #proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;

    # Disable request and response buffering
    proxy_request_buffering  off;
    proxy_buffering          off;
    proxy_http_version       1.1;

    # Add X-Forwarded-* headers so that response can reference https and
    # originating host:port
    proxy_set_header X-Forwarded-Host $host:$server_port;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # Allow proxying of websockets if required
    proxy_set_header         Upgrade $http_upgrade;
    proxy_set_header         Connection "upgrade";
    client_max_body_size     0;
  }

If I take out the line, listen [::]:1081 http2 ipv6only=on ssl; from the server config block, the issue still occurs.

Upon further reading at docker and docker-for-mac, it appears that ipv6 networking is only available for docker daemons running on Linux hosts???

I have tried adding a resolver and setting ipv6only=off but nginx seems to continue to try and send to the upstream proxy with an ipv6 address.

Has anybody else experienced and resolved the same issue when using nginx as a proxy?

Updated
Solved by using http://127.0.0.1:1080 in the proxy. Since this uses an ipv4 address ipv6 is avoided.

Will change back to localhost whenever ipv6 becomes available in Docker for mac :slight_smile:

Kind regards

dcs3spp