Haproxy - angular 1.6.x - rewrite error


#1

Hi everybody,

We have 1 HAproxy in front of 3 apache2 servers in different datacenters.
I deployed a new angular 1.6.x project on all apache2 server.

But when i open the app, it redirect me on https://project.name/login on “Not Found The requested URL /login was not found on this server.”

if i try to use the /login.html it’s works!!

i tried to install the same angular project on a simple apache2 server without haproxy and it’s works.

The problem is HAproxy configuration

global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon

defaults
log global
option forwardfor
option http-server-close
option httplog
option dontlognull
timeout connect 9000

frontend www-http
bind *:80
mode http
reqadd X-Forwarded-Proto:\ http
default_backend www-backend-http

backend www-backend-http
mode http
cookie SERVERID insert indirect nocache
server s1 77.xxx.xxx.xxx:80 check cookie s1 maxconn 500
server s2 77.xxx.xxx.xxx:80 check cookie s2 maxconn 500
server s3 77.xxx.xxx.xxx:80 check cookie s3 maxconn 500

frontend https-in
bind *:443
option tcplog
default_backend ssl-nodes

backend ssl-nodes
mode tcp
balance roundrobin
stick-table type ip size 10M expire 30m
stick on src
option ssl-hello-chk
server web01 77.xxx.xxx.xxx:443 check
server web02 77.xxx.xxx.xxx:443 check
server web03 77.xxx.xxx.xxx:443 check

Any idea how to solve this issue ?


#2

We don’t know about angular, we cannot possibly tell what goes wrong here. You will have to do some basic troubleshooting first.

Take a look at the request between haproxy and your backend. Check your backend logs, maybe tcpdump the HTTP request and compare it with a direct and working configuration.

If you can tell what’s wrong with the request that comes from haproxy, we can help you.


#3

On my backend servers i can see these errors:

haproxy.IP.Address - - [26/Jan/2017:19:24:59 +0100] “GET /login HTTP/1.1” 404 711 “-” "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"
haproxy.IP.Address - - [26/Jan/2017:19:26:38 +0100] “GET /login HTTP/1.1” 404 2693 “-” "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"
haproxy.IP.Address - - [26/Jan/2017:19:26:40 +0100] “GET /login HTTP/1.1” 404 558 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36”


#4

Compare working and non working requests.


#5

This is an example of a good request

[26/Jan/2017:19:44:44 +0100] “GET /js/globals.js HTTP/1.1” 200 602 “https://web.freedyn.it/login.html” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36”

No difference.

I don’t understand if the problem is on haproxy or on the project.

If i put this project in a stand alone server all works good.


#6

You need to take a look at the entire request, including HTTP headers.


#7

It very much looks like the redirect is the problem. Note the lack of a domain name in the failed requests.

Possibly also Apache isn’t configured to the same on all the servers with regard to DirectoryIndex?

It’s very inefficient having the servers do the redirect too, why not let HAProxy do it instead. You are also inserting a cookie which seems rather pointless if you’re just redirecting.


#8

Now, i’m sure that haproxy works OK.
I see in the VirtualHost access log file the error

IP PUB - - [03/Feb/2017:11:38:06 +0100] “GET /login HTTP/1.1” 404 711 “-” "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"
IP PUB - - [03/Feb/2017:11:38:08 +0100] “GET /login HTTP/1.1” 404 558 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36”

The problem in on my apache or project rewrite rules.

Thanks guys for your support!


#9

I found the issue.
it was in apache2.conf ( AllowOverride None ) and the same variable in the VirtualHost file was configured right ( AllowOverride All ), but apache used the value in apache2.conf.

Thanks for your support