I'm using haproxy to loadbalance and get high availability of my (RESTFUL)API, the problem I'm facing is: I can't send REST requests to the API.
I mean haproxy does not support REST API by default and I've figured that I should configure an ACL
to make it work, but I couldn't find anything about configuring RESTFUL Support and enabaling http rewrite rules for haproxy.
MY API is based on laravel framework.
For example If I hit 192.168.1.139/login
I get 404 error message. the only route which is working is /
Which shows the user "you are not logged in." message.
This is haproxy configuration :
listen http_front
bind *:80
mode http
stats enable
stats uri /haproxy?stats
option httpclose
option forwardfor
#acl api_exp hdr(host) -i domain_name.com
#use_backend api_servers if api_exp
default_backend api_servers
backend api_servers
balance roundrobin
server replica1 192.168.100.110:80 check
server replica2 192.168.100.111:80 check
It's a bit strange but I've solved my problem with this configuration :
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
timeout connect 5000
timeout client 100s
timeout server 100s
listen ha-www
bind 0.0.0.0:80
mode http
stats enable
stats uri /haproxy?stats
stats realm Strictly\ Private
balance roundrobin
option httpclose
option forwardfor
server app-www-1 192.168.100.110:80 check
server app-www-2 192.168.100.111:80 check