Can't install AIO behind SWAG on different VM

I’m running Proxmox. There are two VMs.
vm1 has Nextcloud AIO
vm2 has SWAG as a reverse proxy and several other services that are all reachable. nc.mydomain is among the subdomains in SWAG’s docker-compose.

Nextloud AIO is the only service on vm1.
After starting Nextcloud AIO on vm1, I can reach the AIO set-up on ip-vm1:8080
When I enter my domain it says :

Domain does not point to this server or the reverse proxy is not configured correctly. See the mastercontainer logs for more details. ('sudo docker logs -f nextcloud-aio-mastercontainer')

That mastercontainer log says:

[19-Sep-2023 17:40:21] NOTICE: ready to handle connections
{"level":"info","ts":1695145221.19883,"msg":"using provided configuration","config_file":"/Caddyfile","config_adapter":""}
NOTICE: PHP message: The response of the connection attempt to "https://nc.mydomain:443" was: 
NOTICE: PHP message: Expected was: 149e4ce01eed95bf0f25a4d51a8511ed6f085fa6b0c96d1a
NOTICE: PHP message: The error message was: Operation timed out after 10002 milliseconds with 0 bytes received

It seems to me I did not configure my reverse proxy on VM2 properly. My nextcloud.subdomain.conf on SWAG (on VM2) looks like this:

server {
    listen 80;
    listen [::]:80; # comment to disable IPv6
    if ($scheme = "http") {
    return 301 https://$host$request_uri;

    listen 443 ssl http2;
    listen [::]:443 ssl http2; # comment to disable IPv6

    server_name nc.mydomain;
    include /config/nginx/ssl.conf;

    location / {

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 0;

        # Websocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

Going to nc.mydomain says ‘504 Bad gateway’

Any ideas on how I can configure SWAG as a reverse proxy to vm1 in this case?

Hi, can you follow

Thanks. The point was in the last point. skip domain validation. I could install now.