title: How to use nginx on Docker for Windows as reverse proxy for localhost?
body: <p>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 <code>extra_host</code> 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?<br>
  <strong>docker-compose.yml:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>nginx.conf:</strong></p>
  
  <pre><code>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;
      }
  
    }
  
  } 
  </code></pre>
  
  <p><strong>PS:</strong> all referred paths are docker-containers e.g. <code>/auth</code> is a keycloak authentification server</p>