404 error and missing X-Openwisp-Controller header

45 views
Skip to first unread message

yves baumes

unread,
Jul 16, 2021, 11:27:56 AM7/16/21
to OpenWISP

Hello,

I've installed the openwisp agent on a router. And I've installed the openwisp controller on a VirtualBox using the Ansible installation. Now I've configured the agent to automatically register to the controller. But the agent fails in connecting to the controller. Here is the end of the `logread` command:
```
Tue Feb 16 16:42:00 2021 daemon.info openwisp: OpenWISP config agent started
Tue Feb 16 16:42:00 2021 daemon.info openwisp: Registering device...
Tue Feb 16 16:42:01 2021 daemon.err openwisp: Invalid url: missing X-Openwisp-Controller header
Tue Feb 16 16:42:01 2021 daemon.info procd: Instance openwisp_config::instance1 s in a crash loop 7 crashes, 0 seconds since last crash
```

The agent complains the X-Openwisp-Controller header is missing.

Here is the content of the registration_parameter file:
```
root@OpenWrt:~# cat /tmp/openwisp/registration_parameters
HTTP/1.1 404 Not Found
Server: nginx/1.14.2
Date: Fri, 16 Jul 2021 14:48:06 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.14.2</center>
</body>
</html>

```

It returns a 404 error.

Does anyone have an idea? Is there any information on the controller side I can use to solve this issue?

Regards
Yves





Federico Capoano

unread,
Jul 19, 2021, 4:44:09 PM7/19/21
to OpenWISP
Hi Yves,

when this happens, you should verify what URL openwisp-config is trying to fetch and call the same curl command the agent is calling to see the result.

That response is coming from nginx, so nginx is replying 404, the reasons could be many:

- URL is pointing to another server
- Nginx is not finding the uwsgi application server and returning 404

This is how a good response looks like, you can try this command and see what you receive:

curl -v -I "$(uci get openwisp.http.url)"
> HEAD / HTTP/1.1
> Host: openwisp.******.com
> User-Agent: curl/7.77.0
> Accept: */*
< HTTP/1.1 302 Found
HTTP/1.1 302 Found
< Server: nginx/1.18.0 (Ubuntu)
Server: nginx/1.18.0 (Ubuntu)
< Date: Mon, 19 Jul 2021 20:42:37 GMT
Date: Mon, 19 Jul 2021 20:42:37 GMT
< Content-Type: text/html; charset=utf-8
Content-Type: text/html; charset=utf-8
< Content-Length: 0
Content-Length: 0
< Connection: keep-alive
Connection: keep-alive
< Location: /admin/
Location: /admin/
< X-Frame-Options: DENY
X-Frame-Options: DENY
< Vary: Origin, Accept-Language
Vary: Origin, Accept-Language
< Content-Language: en
Content-Language: en
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< Referrer-Policy: same-origin
Referrer-Policy: same-origin
< Strict-Transport-Security: max-age=31536000
Strict-Transport-Security: max-age=31536000
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff

yves baumes

unread,
Jul 20, 2021, 3:35:22 AM7/20/21
to OpenWISP
Thank you very much Federico, actually I finally solved my issue.

The issue came from the fact that my URL was an IP address. It was a valid one, but still a different IP address from the default one in the vagrant file for the controller configuration (192.168.56.5). It looks like the controller server does not like when it's requested from a different IP address... It looks it's some kind of vhost issue that you can have when configuring a web server.

So I finally solved my issue by setting a real URL, that I defined in the /etc/hosts file on the agent's machine. The agent is now registering perfectly well to the controller.

Yves
Reply all
Reply to author
Forward
0 new messages