title: Haproxy SSL termination : Layer4 connection problem, info: "Connection refused"
body: <p>I was trying to implement SSL termination with HAProxy.</p>
  <p>This is how my haproxy.cfg looks like</p>
  <pre><code>frontend Local_Server
      bind *:443 ssl crt /home/vagrant/ingress-certificate/k8s.pem
      mode tcp
      reqadd X-Forwarded-Proto:\ https
      default_backend k8s_server
  
  backend k8s_server
      mode tcp
      balance roundrobin
      redirect scheme https if !{ ssl_fc }
      server web1 100.0.0.2:8080 check
  </code></pre>
  <p>I have generated the self signed certificate which k8s.pem.</p>
  <p>My normal URL <strong>(without https)</strong> is working perfectly fine .i.e. - <a href="http://100.0.0.2/hello" rel="nofollow noreferrer">http://100.0.0.2/hello</a></p>
  <p>But when i try to access the same url with <strong>HTTPS</strong> .i.e.- <a href="https://100.0.0.2/hello" rel="nofollow noreferrer">https://100.0.0.2/hello</a> i get 404 and when i checked my haproxy logs i can see following message</p>
  <pre><code>Jul 21 18:10:19 node1 haproxy[10813]: Server k8s_server/web1 is DOWN, reason: Layer4 connection problem, info: &quot;Connection refused&quot;, check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
  Jul 21 18:10:19 node1 haproxy[10813]: Server k8s_server/web1 is DOWN, reason: Layer4 connection problem, info: &quot;Connection refused&quot;, check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
  </code></pre>
  <p>Any suggestions which i can incorporate in my haproxy.cfg ?</p>
  <p>PS - The microservice which i am trying to access is deployed under kubernetes cluster with service exposed as ClusterIP</p>