I have been messing around and got different results now. I have this network for virtsh:
$ sudo virsh net-dumpxml default
<network connections='1'>
<name>default</name>
<uuid>3355001d-8a93-436d-82b2-4c1b81121997</uuid>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:59:f1:b4'/>
<dns enable='no'/>
<ip address='192.168.122.1' netmask='255.255.255.0'/>
</network>
Installed the image with this command:
sudo virt-install \
--name haos \
--memory memory=4096,currentMemory=1024 \
--vcpus 2 \
--cpu host \
--machine q35 \
--disk /var/lib/libvirt/images/haos_ova-18.2.qcow2,format=qcow2,bus=virtio \
--os-variant generic \
--network network=default,model=virtio \
--graphics none \
--video none \
--console pty,target_type=serial \
--boot uefi \
--memballoon virtio \
--import --noautoconsole
After waiting a bit I can enter the console of the VM:
sudo virsh -e '^c' console haos
Inside the VM I do some setup to assign an IP and setup DNS, because on the host I am running Technitium DNS Server and dnsmasq would otherwise conflict with that:
(
c=$(nmcli c show | awk '$NF != "lo" && $NF != "DEVICE" { a = $1; for (i = 2; i < NF; i++) { if (length($i) == 36) break; a = a " " $i } print a }')
nmcli c modify "$c" \
ipv4.method manual \
ipv4.addresses 192.168.122.121/24 \
ipv4.gateway 192.168.122.1 \
ipv4.dns 192.168.122.1 \
ipv4.ignore-auto-dns yes \
autoconnect yes \
&& nmcli c down "$c" && nmcli c up "$c"
)
mkdir .ssh 2> /dev/null; printf %s\\n 'ssh-ed25519 ...' > .ssh/authorized_keys
systemctl enable --now dropbear
ha dns options --fallback=false && ha dns options --servers dns://192.168.122.1
This also makes the server accessible with ssh -t -p 22222 [email protected].
The exact server block in nginx:
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name ha.mini.lan;
ssl_certificate /etc/ssl/nginx/mini.lan.crt;
ssl_certificate_key /etc/ssl/nginx/mini.lan.key;
proxy_buffering off;
location / {
proxy_redirect http:// https://;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 60s;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_pass http://192.168.122.121:8123;
}
}
Now my issue is that HA gives me a redirect loop:
$ curl -s -k -I https://ha.mini.lan | grep -ie location: # via nginx
location: https://ha.mini.lan/
$ curl -s -I http://192.168.122.121:8123 | grep -ie location: # direct
Location: http://192.168.122.121/
$ curl http://192.168.122.121:80 # prints nothing