openwisp / openwisp-config

OpenWRT configuration agent for OpenWISP Controller
https://openwisp.io/docs/dev/openwrt-config-agent/
GNU General Public License v3.0
374 stars 58 forks source link

[agent] Invalid url: missing X-Openwisp-Controller header #110

Closed glassen closed 4 years ago

glassen commented 4 years ago

Good day,

I'm having an issue when using ansible-openwisp2 behind a HAProxy reverse proxy. HAProxy makes all headers lowercase per HTTP/2 from what i can read in https://http2.github.io/http2-spec/#rfc.section.8.1.2 The openwisp-config agent is case sensitive when checking the header. Adding an i in the grep check will make it case insensitive.

Like so: local is_controller=$(grep -ic "X-Openwisp-Controller: true" $1)

instead of the current check https://github.com/openwisp/openwisp-config/blob/fc04e62eace3f7d43b07bb19bbf6edb8b2b7ba1b/openwisp-config/files/openwisp.agent#L121

Tested with OpenWrt 18.06.5 r7897-9d401013fc on a MediaTek MT7620A and OpenWrt 19.07.2 r10947-65030d81f3 in a virtual machine. It worked for me, but i have not really made any larger compatibility tests.

nemesifier commented 4 years ago

@glassen please send a patch