title: 502 Bad Gateway Haproxy in server
body: <p>We have a server running on port 8080, whenever posting a request to the server it is giving response back.</p>
  
  <p>On the same instance Haproxy is running on 443 (with SSL), when I'm posting the the same request to haproxy (IP:443) it is throwing "502 Bad Gateway" error.</p>
  
  <p>May I know what could be the problem?</p>
  
  <p>Below is the Haproxy config:</p>
  
  <pre><code>global
      maxconn     2048
      tune.ssl.default-dh-param 2048
      daemon
  
  defaults
      mode                    http
      option          forwardfor
      option          http-server-close
      retries                 3
      timeout http-request    5000s
      timeout queue           3m
      timeout connect         5000s
      timeout client          3m
      timeout server          3m
      timeout http-keep-alive 5000s
      timeout check           4000s
      maxconn                 2048
  
  frontend www-https
      bind *:443 ssl crt /etc/ssl/haproxy/app-ssl.pem
      reqadd X-Forwarded-Proto:\ https
      default_backend www-backend
  
  backend www-backend
      redirect scheme https if !{ ssl_fc }
      server www-1 localhost:8080 check
  
  listen stats
       bind *:28080
       mode http
       stats enable
       stats uri /haproxy?stats
  </code></pre>