I am trying to enable maas native tls on HA environment. I generated a self signed certificate using my own csr.
Do I need to run the command maas enable-tls on every node and use the same certificate and key file or only on one node?
After all I assume that the command only does some change to maas DB.
In the documentation I can only see some information regarding subject alternative name in the csr which makes me believe that running enable tls needs to be run in one machine only?
@billwear maybe you can share some of your expertise on that?
enable-tls will put the provided key/cert files to the database and change MAAS config parameter. There is a PostgreSQL Trigger function, that will detect that change and fire PostgreSQL NOTIFY event, which will be captured by all MAAS Region Controllers, leading to a restart of the HTTP Reverse proxy service and generation of a correct nginx config file.
Thank you very much for your response. Now it’s clear.
So now when I have tls enabled do I have to change the haproxy backend settings to point to my desired tls port(in my case 5443)? Or should the rewrite work by default on region controller level?
Maybe you happen to have an example haproxy config for maas with tls enabled?
@billwear@troyanov would it be possible to add such example to documentation?
You can configure HAProxy with mode tcp (IIRC that needs to be provided both for the backend and frontend blocks), so it simply proxies the traffic to MAAS nginx instance, and hence the TLS termination will be done by nginx.
@troyanov thanks for quick response, before implementing ssl I was able to loadbalance using simple configuration, now for some reason it does not work anymore, now I use
global
maxconn 100
defaults
log global
mode tcp
retries 2
timeout client 30m
timeout connect 4s
timeout server 30m
timeout check 5s
frontend maas_region_controller-v4
bind 10.10.10.10:5240
mode tcp
use_backend maas_region_controllers
backend maas_region_controllers
balance roundrobin
server maas-ha-1 10.10.10.101:5240
server maas-ha-2 10.10.10.102:5240
The requests look like(10.10.10.104 is my haproxy) :
url -i -L -X GET http://10.10.10.104:5240/MAAS
HTTP/1.1 301 Moved Permanently
server: nginx/1.18.0 (Ubuntu)
date: Wed, 01 Mar 2023 13:06:16 GMT
content-type: text/html
content-length: 178
location: https://10.10.10.104:5443/MAAS
curl: (28) Failed to connect to 10.10.10.104 port 5443 after 21079 ms: Timed out
If I understand correctly, you visit {HAProxy_IP}:{HAProxy_Port_5240}, and since MAAS is configured with TLS, it will redirect 5240 to 5443, which will become {HAProxy_IP}:{5443}, but there is no 5443 listener on HAProxy (you listen only 5240)
I believe that might be related to this bug and it was fixed.
Which version of MAAS you are using?
It is working now
The initial cause was the lack of iptables INPUT chain rule but then I had to do some trial and error stuff with HAproxy backend too.