• 7
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Request doesn't hit port 80 on HAproxy

I'm configuring HAProxy to redirect http to https, but it doesn't seem to work. The configuration I use is:

/etc/hosts content

127.0.0.1 example.com

Haproxy configuration

frontend http
  mode http
  bind :80
  bind :443 ssl crt /etc/ssl/
  redirect scheme https if !{ ssl_fc }

  default_backend my_backend

Testing with curl give this error

$ curl https://example.com < this works 
$ curl http://example.com 
> curl: (7) Failed to connect to 2400:cb00:2048:1::681c:a20: No route to host

However, command lsof has output

$ sudo lsof -i :80 | grep LISTEN
haproxy   7290 root    4u  IPv4 0x9485b36892b5495d      0t0  TCP *:http (LISTEN)

I'm out of idea what's wrong in this situation. This is the first time I configure SSL on Haproxy.

I have a very similar set up in HAProxy which works. I can only find two differences between your configuration and mine.

  1. In /etc/hosts I have bound example.com to 0.0.0.0 rather than 127.0.0.1.
  2. In my frontend, both bind entries contain a wildcard (*) in front of the colon. Example:

    bind *:80
    bind *:443 ssl crt /etc/ssl/ssl.pem
    

    2a. I actually used a pem file in my configuration (as above) but seeing as curl https://example.com worked it is unlikely this is the problem.

I would also suggest looking at the output of netstat -tulpn | grep haproxy for more detail on where HAProxy is binding.

Hope that helps.

  • 1
Reply Report

Trending Tags