Reputation: 539
We have a server running on port 8080, whenever posting a request to the server it is giving response back.
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.
May I know what could be the problem?
Below is the Haproxy config:
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
Upvotes: 3
Views: 5070
Reputation: 539
Add Global value
tune.maxrewrite 4096
then it worked
Haproxy Config should be as below:
global
maxconn 2048
tune.ssl.default-dh-param 2048
tune.maxrewrite 4096
daemon
defaults
mode http
option forwardfor
option http-server-close
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 2048
frontend www-https
bind *:443 ssl crt /etc/ssl/haproxy/ede-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
Please find the below description:
tune.bufsize Sets the buffer size to this size (in bytes). Lower values allow more sessions to coexist in the same amount of RAM, and higher values allow some applications with very large cookies to work. The default value is 16384 and can be changed at build time. It is strongly recommended not to change this from the default value, as very low values will break some services such as statistics, and values larger than default size will increase memory usage, possibly causing the system to run out of memory. At least the global maxconn parameter should be decreased by the same factor as this one is increased. If HTTP request is larger than (tune.bufsize - tune.maxrewrite), haproxy will return HTTP 400 (Bad Request) error. Similarly if an HTTP response is larger than this size, haproxy will return HTTP 502 (Bad Gateway)
Upvotes: 4