Welcome! Log In Create A New Profile

Advanced

How to disable ipv6 in nginx?

rough lea
November 15, 2018 06:12AM
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"_

My nginx configuration is 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](https://docs.docker.com/config/daemon/ipv6/) and [docker-for-mac](https://github.com/docker/for-mac/issues/1432), 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.

How can I get nginx to use ipv4 only? Has anybody else experienced and resolved the same issue?


Kind regards

Simon
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to disable ipv6 in nginx?

rough lea November 15, 2018 06:12AM

Re: How to disable ipv6 in nginx?

Francis Daly November 15, 2018 09:16AM

Re: How to disable ipv6 in nginx?

Maxim Dounin November 15, 2018 09:26AM

Re: How to disable ipv6 in nginx?

rough lea November 15, 2018 09:38AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 118
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready