Nginx returns "upstream timed out" when IPv6 is enabled on the host


#1

I have both nginx v1.15.7 and gitea 1.6.0 running on a Windows 2016 server VM.
It seems as gitea always resolves “localhost” to IPv4 address even though, by default, Windows Server prioritizes IPv6 over IPv4. Nginx resolves “localhost” based on the current Windows prioritization thus preventing the proxy from working.

Gitea config:

[server]
PROTOCOL         = https
DOMAIN           = localhost.contoso.com
HTTP_ADDR        = localhost.contoso.com
HTTP_PORT        = 3000
CERT_FILE        = C:/Inet/cert/contoso.pem
KEY_FILE         = C:/Inet/cert/contoso.pem
ROOT_URL         = https://git.contoso.com/

Nginx config:

server {
    listen                  public.contoso.com:443 ssl;
    server_name             ~(?i)^git\.contoso\.com$;

    location /              {
        proxy_pass          https://localhost.contoso.com:3000;
    }
}

Contoso DNS server config:

localhost.contoso.com      ::1            OK
localhost.contoso.com      127.0.0.1      OK
localhost.contoso.com      localhost      Nginx proxy returns "upstream timed out"

Is this a gitea bug or is there any way to force gitea to resolve “localhost” according to current host prioritization?


#2

Why do you not change your vhost config to 127.0.0.1 instead of the localhost?


#3

We have a valid CA signed certificate for our domain. With https enabled, the browser won’t let you access 127.0.0.1