How to use nginx on Docker for Windows as reverse proxy for localhost?

I am using Docker for Windows and want to set up nginx as reverse proxy. All is working fine but if I want to define a proxy to my localhost I always get a 502 or 504 error. I thought setting an extra_host would solve my problem but didn’t. Is there any other IP that I can try to set as host or is something else wrong?
docker-compose.yml:

version: '3'

volumes:
  etc:
      driver: local

services:
  nginx:
      container_name: nginx
      image: nginx:latest
      volumes:
        - ./etc:/etc/nginx
      ports:
        - 8088:80
      extra_hosts:
        - localhost:127.0.0.1

nginx.conf:

user  nginx;
worker_processes  1;

events { 
}

http {
  server {
    listen 80;
    server_name localhost;

    location /auth {
      proxy_pass http://localhost:8082/auth;
    }

    location /graphql {

        proxy_pass http://localhost:8080/graphql;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_http_version 1.1;

    }

    location ^~ / {
        proxy_pass http://localhost:8082/auth;
    }

    location /sso/login {
        proxy_pass http://localhost:8082/auth;
    }

  }

} 

PS: all referred paths are docker-containers e.g. /auth is a keycloak authentification server

Source: StackOverflow