Comment 2 for bug 1993618

Revision history for this message
Samuel Allan (samuelallan) wrote : Re: web ui redirects invalid behind haproxy

Here is a way to reproduce this issue in a lab:

1. create three focal VMs:

```
uvt-simplestreams-libvirt sync release=focal arch=amd64
uvt-kvm create maas1 release=focal --memory 16000 --disk 30
uvt-kvm create maas2 release=focal --memory 16000 --disk 30
uvt-kvm create maas3 release=focal --memory 16000 --disk 30
```

2. retrieve the ip addresses of them:

```
virsh domifaddr maas1
virsh domifaddr maas2
virsh domifaddr maas3
```

We'll refer to the addresses as $IP1, $IP2, and $IP3 below respectively.

3. create an ansible hosts file with the following contents:

```
[maas1]
$IP1

[maas2]
$IP2

[maas3]
$IP3

[maas_postgres_primary:children]
maas1

[maas_postgres_secondary:children]
maas2
maas3

[maas_postgres:children]
maas_postgres_primary
maas_postgres_secondary

[maas_region_controller:children]
maas1

[maas_rack_controller:children]
maas1

[maas_proxy:children]
maas1
```

4. create an ansible variables file with the following contents:

```
maas_version: "3.2"
maas_postgres_password: mypassword
maas_installation_type: snap
maas_url: http://$IP1:5050/MAAS
ansible_user: ubuntu
```

5. clone the new maas-ansible-playbook repository: https://github.com/maas/maas-ansible-playbook . At time of writing, main is at commit db80c9b7ebefd069809e6368e280ed38cd968532 .

6. Run the site.yaml playbook with the above hosts and vars to deploy maas - eg.:

```
ansible-playbook -i hosts --extra-vars "@vars.yaml" ./site.yaml
```

7. now visit http://$IP1:5050/MAAS/r/ in the browser. This is the address that the haproxy instance is listening on. Verify that the maas web ui loads and remains on the same url.

8. now visit http://$IP1:5050/ . Verify that you will be redirected to http://$IP1:5240/MAAS/r/ . Note the changed port number - this is the evidence of the bug here. Now you're directly accessing the url of the maas server, not the haproxy.

When the bug is fixed, it can be confirmed by checking that in step 8, you are redirected to http://$IP1:5050/MAAS/r/ (ie. retaining the correct port - remaining on haproxy).