Index: /etc/rc.d/rc.nginx
===================================================================
--- /etc/rc.d/rc.nginx	original
+++ /etc/rc.d/rc.nginx	modified
@@ -26,11 +26,12 @@
 SERVERS="/etc/nginx/conf.d/servers.conf"
 LOCATIONS="/etc/nginx/conf.d/locations.conf"
 INI="/var/local/emhttp/nginx.ini.new"
 CERTPATH="$SSL/certs/certificate_bundle.pem"
 TSCERTPATH="$SSL/certs/ts_bundle.pem"
-MYSERVERS="/boot/config/plugins/dynamix.my.servers/myservers.cfg"
+CONNECT_CONFIG="/boot/config/plugins/dynamix.my.servers/configs/connect.json"
+API_UTILS="/usr/local/share/dynamix.unraid.net/scripts/api_utils.sh"
 DEFAULTS="/etc/default/nginx"
 SYSTEM="/sys/class/net"
 SYSLOG="/var/log/syslog"
 
 # Load defaults
@@ -73,10 +74,27 @@
 
 fqdn(){
   echo ${CERTNAME/'*'/${1//[.:]/-}}
 }
 
+# check if remote access should be enabled
+check_remote_access(){
+  # Check if connect plugin is enabled using api_utils.sh
+  if [[ -f $API_UTILS ]] && $API_UTILS is_api_plugin_enabled "unraid-api-plugin-connect"; then
+    # Plugin is enabled, check connect.json configuration
+    if [[ -f $CONNECT_CONFIG ]] && command -v jq >/dev/null 2>&1; then
+      local wanaccess=$(jq -r '.wanaccess' "$CONNECT_CONFIG" 2>/dev/null)
+      local username=$(jq -r '.username' "$CONNECT_CONFIG" 2>/dev/null)
+      # Enable remote access if wanaccess is true and username is not empty
+      if [[ $wanaccess == "true" && -n $username && $username != "null" ]]; then
+        return 0
+      fi
+    fi
+  fi
+  return 1
+}
+
 # create listening ports
 listen(){
   T='    '
   if check && [[ $1 == lo ]]; then
     if [[ $IPV4 == yes ]]; then
@@ -566,11 +584,11 @@
     # extract common name from cert
     CERTNAME=$(openssl x509 -noout -subject -nameopt multiline -in $CERTPATH | sed -n 's/ *commonName *= //p')
     # define CSP frame-ancestors for cert
     CERTFA="https://*.${CERTNAME#*.}/"
     # check if Remote Access is enabled and fetch WANIP
-    if [[ -L /usr/local/sbin/unraid-api ]] && grep -qs 'wanaccess="yes"' $MYSERVERS && ! grep -qs 'username=""' $MYSERVERS; then
+    if [[ -L /usr/local/sbin/unraid-api ]] && check_remote_access; then
       WANACCESS=yes
       WANIP=$(curl https://wanip4.unraid.net/ 2>/dev/null)
       WANIP6=$(curl https://wanip6.unraid.net/ 2>/dev/null)
     fi
     if [[ $CERTNAME == *\.myunraid\.net ]]; then
@@ -660,14 +678,14 @@
   echo "NGINX_WANFQDN=\"$WANFQDN\"" >>$INI
   echo "NGINX_WANFQDN6=\"$WANFQDN6\"" >>$INI
   # defined if ts_bundle.pem present:
   echo "NGINX_TAILSCALEFQDN=\"$TSFQDN\"" >>$INI
   # add included interfaces
-  for NET in ${!NET_FQDN[@]}; do
+  for NET in "${!NET_FQDN[@]}"; do
     echo "NGINX_${NET^^}FQDN=\"${NET_FQDN[$NET]}\"" >>$INI
   done
-  for NET in ${!NET_FQDN6[@]}; do
+  for NET in "${!NET_FQDN6[@]}"; do
     echo "NGINX_${NET^^}FQDN6=\"${NET_FQDN6[$NET]}\"" >>$INI
   done
   # atomically update file
   mv $INI ${INI%.*}
 }
