Stream Deck and HA api connection problem under Duckdns

Hello everyone,

I recently installed HA on my local server, but I have a little problem with the API connection for my Stream Deck when I want to go through DuckDNS.

image

Locally everything works perfectly except that my PC is regularly on a 4G network other than my local network hence the use of duckdns in order to be able to control my HA even if my pc is on another network

to know that all my server is under Docker as well as swag/nginx and that I opened port 8123 temporarily to try directly with my ip and it works.

How can I solve this problem?

My current code in nginx :

 map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name homeassistant.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;
	

    location / {

        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app homeassistant;
        set $upstream_port 8123;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";


    }

    location ~ ^/(api|local|media)/ {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app homeassistant;
        set $upstream_port 8123;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";


    }
}