{"id":3032,"date":"2026-11-16T14:46:25","date_gmt":"2026-11-16T14:46:25","guid":{"rendered":"https:\/\/hostry.com\/blog\/?p=3032"},"modified":"2026-11-16T14:46:26","modified_gmt":"2026-11-16T14:46:26","slug":"ai-agent-exposed-to-internet-vps","status":"publish","type":"post","link":"https:\/\/hostry.com\/blog\/ai-agent-exposed-to-internet-vps\/","title":{"rendered":"AI Agent Exposed to the Internet? What UFW Misses on a VPS"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-cover.webp\" alt=\"Checking whether an AI agent is exposed to the internet on a VPS: a control desk showing which ports answer from outside and which stay closed\" class=\"wp-image-3029\" srcset=\"https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-cover.webp 1200w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-cover-300x169.webp 300w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-cover-1024x576.webp 1024w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-cover-450x253.webp 450w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-cover-768x432.webp 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\" style=\"font-size:14px\"><em><strong>On a lab host where UFW allowed only 22, 80 and 443, a Docker-published port 8188 still answered from a second machine; scanning just the ports that ss listed found it in 1.22 seconds, while a full sweep took 104.85 seconds. Whether an AI agent is exposed to the internet comes down to two questions: what answers on your public address from outside, and which of those answers without credentials.<\/strong><\/em><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On a <strong><a href=\"https:\/\/hostry.com\/products\/vps\/\">Linux VPS<\/a><\/strong> you hold every layer that decides this: the bind address of each agent, Docker&#8217;s own forwarding rules, the host firewall and the reverse proxy in front. The check takes about ten minutes and changes nothing until you start closing ports.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every command and output here was reproduced with Docker 29.9.2 (iptables and nftables firewall backends) on Ubuntu 24.04.5, with n8n 2.47.7 and OpenClaw 2026.11.4 in a locally built container.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ufw 0.36.2 ran in an isolated network namespace, and the outside probes came from a second machine on the same network segment, not over the internet, so real scan times are longer. In the output the server is 203.0.113.10, the other machine 203.0.113.20, and 198.51.100.10 the second lab host used for the nftables backend; all are documentation addresses, so use your own.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Find an AI agent exposed to the internet in ten minutes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A Mysterium VPN scan published on September 10, 2026, counted 36,769 self-hosted AI endpoints reachable from the internet, and only 741 of them (2.02%) answered with an HTTP authentication challenge, according to <strong><a href=\"https:\/\/www.esecurityplanet.com\/news\/news-self-hosted-ai-security\/\" target=\"_blank\" rel=\"noopener\">eSecurity Planet&#8217;s report on the scan<\/a><\/strong>; some of the rest may still show their own login page, which is why step 4 reads what each open port returns.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run steps 1 to 3 as root on the VPS and step 4 from a laptop or a second server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\"><strong>1. List every listener and its process<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ss -ltnp<\/code> prints the TCP listeners with the owning process; <code>ss -lunp<\/code> does the same for UDP, which an AI panel rarely uses. On the lab host it showed six listeners, five of them on <code>0.0.0.0<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ss -ltnp\nLISTEN 0 511      0.0.0.0:18789   0.0.0.0:*   users:((\"openclaw-gatewa\",pid=916,fd=79))\nLISTEN 0 4096     0.0.0.0:8188    0.0.0.0:*   users:((\"docker-proxy\",pid=1669,fd=9))\nLISTEN 0 5        0.0.0.0:8081    0.0.0.0:*   users:((\"python3\",pid=22916,fd=3))\nLISTEN 0 511      0.0.0.0:80      0.0.0.0:*   users:((\"nginx\",pid=32060,fd=5),(\"nginx\",pid=32059,fd=5))\nLISTEN 0 511      0.0.0.0:443     0.0.0.0:*   users:((\"nginx\",pid=32060,fd=6),(\"nginx\",pid=32059,fd=6))\nLISTEN 0 4096   127.0.0.1:5678    0.0.0.0:*   users:((\"docker-proxy\",pid=728,fd=9))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\"><strong>2. Classify each listener by its address<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A local address of <code>127.0.0.1<\/code> or <code>::1<\/code> is loopback and safe on its own. <code>0.0.0.0<\/code>, <code>*<\/code> or <code>::<\/code> means every interface, so the host firewall is the only thing between it and the internet. A listener owned by <span class=\"highlighted\">docker-proxy<\/span> was published by Docker, the case the host firewall may not cover. This one-liner labels each line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ss -ltnpH | awk '{a=$4; p=$6; sub(\/^users:\\(\\(\"\/,\"\",p); sub(\/\".*\/,\"\",p);\n    if (a ~ \/^(127\\.|\\[::1\\]|\\[::ffff:127\\.)\/) c=\"loopback only\";\n    else if (a ~ \/^(0\\.0\\.0\\.0|\\*|\\[::\\]):\/) c=\"ALL INTERFACES\";\n    else c=\"one address\";\n    if (p==\"docker-proxy\") c=c\", published by Docker\";\n    printf \"%-22s %-16s %s\\n\", a, p, c}'\n0.0.0.0:18789          openclaw-gatewa  ALL INTERFACES\n0.0.0.0:8188           docker-proxy     ALL INTERFACES, published by Docker\n0.0.0.0:8081           python3          ALL INTERFACES\n0.0.0.0:80             nginx            ALL INTERFACES\n0.0.0.0:443            nginx            ALL INTERFACES\n127.0.0.1:5678         docker-proxy     loopback only, published by Docker<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\"><strong>3. Read the firewall backend, then match published ports to containers<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Read Docker&#8217;s firewall backend first: the nat-table command below works on the iptables backend and errors on nftables, where <code>nft list chain ip docker-bridges nat-prerouting-and-output<\/code> shows the same DNAT rules. Then compare what Docker published with what <code>ufw status<\/code> allows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker info | grep 'Firewall Backend'\n Firewall Backend: iptables\n$ docker ps --format \"table {{.Names}}\\t{{.Ports}}\"\nNAMES       PORTS\nai-web      0.0.0.0:8188-&gt;8000\/tcp\nai-n8n-c5   127.0.0.1:5678-&gt;5678\/tcp\n$ iptables -t nat -S DOCKER | grep DNAT     # published ports: these skip the INPUT chain\n-A DOCKER -d 127.0.0.1\/32 ! -i docker0 -p tcp -m tcp --dport 5678 -j DNAT --to-destination 172.17.0.2:5678\n-A DOCKER ! -i docker0 -p tcp -m tcp --dport 8188 -j DNAT --to-destination 172.17.0.3:8000\n$ ufw status\n22\/tcp                     ALLOW       Anywhere\n80\/tcp                     ALLOW       Anywhere\n443\/tcp                    ALLOW       Anywhere<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">UFW lists 22, 80 and 443. The 8188 container is not in that list, yet its DNAT rule has no loopback restriction, so it is forwarded from any source.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"800\" src=\"https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-check-flow.webp\" alt=\"Flow of the 10-minute check: ss -ltnp lists listeners, each is classified as loopback only, all interfaces or published by Docker, then probed from a second host, and closed by putting the app or the published port on 127.0.0.1 behind one proxy\" class=\"wp-image-3021\" srcset=\"https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-check-flow.webp 1200w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-check-flow-300x200.webp 300w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-check-flow-1024x683.webp 1024w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-check-flow-450x300.webp 450w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-check-flow-768x512.webp 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\"><strong>4. Probe the public address from outside<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Only a connection from off the box tells you what the internet sees, and a full TCP sweep is slow against a host that drops instead of rejecting. Build PORTS on the VPS, then use that value for the targeted scan on the second machine:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ nmap -Pn -sT -p- --open 203.0.113.10\nNot shown: 65531 filtered tcp ports (no-response), 1 closed tcp port (conn-refused)\n80\/tcp   open  http\n443\/tcp  open  https\n8188\/tcp open  unknown\nNmap done: 1 IP address (1 host up) scanned in 104.85 seconds\n\n# faster: scan only the ports ss listed (PORTS built on the server)\n$ PORTS=$(ss -ltnH | awk '{n=split($4,a,\":\"); print a[n]}' | sort -un | paste -sd,)   # -&gt; 80,443,5678,8081,8188,18789\n$ nmap -Pn -sT -p $PORTS 203.0.113.10\n80\/tcp    open     http\n443\/tcp   open     https\n5678\/tcp  filtered rrac\n8081\/tcp  filtered blackice-icecap\n8188\/tcp  open     unknown\n18789\/tcp filtered unknown\nNmap done: 1 IP address (1 host up) scanned in 1.22 seconds<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both scans give the same answer: <strong>8188 is open from outside<\/strong>. The 8081 and 18789 listeners show <code>filtered<\/code> because UFW drops them today, but both bind all interfaces, so they are one firewall edit away from public. Finish by curling each open port and reading the status and content type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -sk -m 5 -o \/dev\/null -w \"%{http_code} %{content_type}\" http:\/\/203.0.113.10:8188\/  -&gt; 200 text\/html<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\"><strong>Before you close anything<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From here on the commands change the server, and the firewall ones need root or sudo. Open the provider console first and confirm you can log in there; in the Hostry control panel that is the VNC console, which gets you a login prompt even with SSH cut off. For firewall edits, consider a self-reverting rollback like the systemd timer armed in <strong><a href=\"https:\/\/hostry.com\/blog\/ssh-over-wireguard-ubuntu-24-04\/\">the guide to closing port 22 behind WireGuard<\/a><\/strong>; SSH keys, a sudo user and UFW defaults come from <strong><a href=\"https:\/\/hostry.com\/blog\/secure-new-linux-vps-first-30-minutes\/\">the first-30-minutes setup for a new Linux server<\/a><\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">n8n listens on every interface by default<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">n8n&#8217;s documented default for <code>N8N_LISTEN_ADDRESS<\/code> is <code>::<\/code>, which Node.js on most systems also opens on <code>0.0.0.0<\/code>, so n8n answers on every interface (not reproduced: the lab kernel had IPv6 off). If you expose n8n before creating the owner account, the first visitor gets the setup screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A fresh instance reachable from the second machine answered anonymous requests on 2.47.7 like this, each line one <code>curl -s -o \/dev\/null -m 5 -w '%{http_code}'<\/code> for the path:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># n8n 2.47.7 bare, N8N_LISTEN_ADDRESS=0.0.0.0; from the second machine (no auth)\n\/setup                   200\n\/healthz                 200\n\/metrics                 404\n\/rest\/settings           200\n\/rest\/workflows          401\n[...]\nshowSetupOnFirstLoad: {\"showSetupOnFirstLoad\":true,\"authenticationMethod\":\"email\"}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create the owner account over a tunnel or a trusted network before the port is public, and bind the service to loopback in the meantime. On the lab&#8217;s IPv6-disabled kernel the <code>::<\/code> default would not even start, exiting six seconds in; <code>N8N_LISTEN_ADDRESS=127.0.0.1<\/code> gave a clean loopback listener, reachable on the host and not from outside:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># N8N_LISTEN_ADDRESS=127.0.0.1 (port 5688 here only because 5678 was busy; yours stays 5678)\nn8n ready on 127.0.0.1, port 5688\nLISTEN 0 511  127.0.0.1:5679  0.0.0.0:*  users:((\"n8n start\",pid=5234,fd=27))\nLISTEN 0 511  127.0.0.1:5688  0.0.0.0:*  users:((\"n8n start\",pid=5234,fd=22))\nfrom the second machine: http:\/\/203.0.113.10:5688\/healthz -&gt; 000\non the host:             http:\/\/127.0.0.1:5688\/healthz    -&gt; 200<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">OpenClaw is loopback on a host but 0.0.0.0 in a container<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On a host, 2026.11.4 started with <code>openclaw gateway<\/code> and no <code>gateway.bind<\/code> in <span class=\"highlighted\">~\/.openclaw\/openclaw.json<\/span> listens on <code>127.0.0.1:18789<\/code> and generates a runtime token that changes on every restart. The same release inside a container, detected through <code>\/.dockerenv<\/code>, switches to <code>auto<\/code>, which resolves to <code>0.0.0.0<\/code>, and refuses to start at all without a token or password. With a token and <code>-p 18789:18789<\/code>, the Control UI answers from outside:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># host, { gateway: { mode: \"local\" } }, bind unset\nLISTEN 0 511  127.0.0.1:18789  0.0.0.0:*  users:((\"openclaw-gatewa\",pid=5477,fd=75))\nfrom the second machine: 000 ; on the host: 200\n\n# container, same config, no token\nRefusing to bind gateway to auto without auth.\nContainer environment detected [...] the gateway defaults to bind=auto (0.0.0.0) for port-forwarding compatibility.\n\n# container, same config, OPENCLAW_GATEWAY_TOKEN set, -p 18789:18789\nLISTEN 0 4096  0.0.0.0:18789  0.0.0.0:*  users:((\"docker-proxy\",pid=3439,fd=9))\nfrom outside: 200 ; on the host: 200<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration docs bundled with 2026.11.4 describe the opposite default:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>The default loopback bind listens on 127.0.0.1 inside the container. With Docker bridge networking (-p 18789:18789), traffic arrives on eth0, so the gateway is unreachable.<\/p><cite>OpenClaw docs bundled with 2026.11.4 (config-gateway.md)<\/cite><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Inside a detected container the code and the behavior both use <code>auto<\/code>, so do not rely on that note. The live <strong><a href=\"https:\/\/docs.openclaw.ai\/gateway\/security\/network-exposure\" target=\"_blank\" rel=\"noopener\">OpenClaw network-exposure guide<\/a><\/strong> matches the code: loopback on a host, <code>auto<\/code> in a container, non-loopback fails closed without auth. A bare host alias is rejected as a bind value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># bind: \"lan\" with no auth\n### result: exited rc=78 after 6 s\nRefusing to bind gateway to lan without auth.\n\n# bind: \"127.0.0.1\"\ngateway.bind: Invalid input (allowed: \"auto\", \"lan\", \"loopback\", \"custom\", \"tailnet\"), got: \"127.0.0.1\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For an explicit loopback-only gateway use <code>bind: \"loopback\"<\/code>, or <code>bind: \"custom\"<\/code> with <code>gateway.customBindHost: \"127.0.0.1\"<\/code> when you want to name the address. In a container, <code>bind: \"loopback\"<\/code> with the port still published as <code>-p 18789:18789<\/code> leaves <code>ss<\/code> on the host showing docker-proxy on <code>0.0.0.0:18789<\/code> while nothing answers (outside gets no connection, the host gets a reset). <strong><a href=\"https:\/\/hostry.com\/blog\/hermes-agent-vs-openclaw-vps\/\">Our comparison of Hermes Agent with OpenClaw<\/a><\/strong> covers choosing and sizing either one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Do Docker published ports bypass UFW? Yes on iptables, no on nftables<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On Docker&#8217;s default iptables backend they do: Docker rewrites the destination in the nat table, so a published port is forwarded and never reaches the INPUT chain that holds UFW&#8217;s allow and deny rules. Switch Docker 29 to its nftables backend and the result flips: the published port falls under UFW&#8217;s routed rules and a routed deny closes it; step 3 shows which backend you run.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With the default iptables backend on 29.9.2, a port published as <code>-p 5678:5678<\/code> answered from the second machine while a bare listener on 8081 was dropped, and <code>ufw deny 5678\/tcp<\/code> changed nothing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ufw deny 5678\/tcp\n$ nmap -sT -Pn -p 22,5678,8081 203.0.113.10   # from the second machine\n22\/tcp   closed   ssh\n5678\/tcp open     rrac\n8081\/tcp filtered blackice-icecap<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ufw route deny proto tcp from any to any port 5678<\/code> left the port reachable as well. So did a plain <code>iptables -A INPUT -j DROP<\/code> without UFW, with loopback, established traffic and SSH accepted above it; Docker&#8217;s DNAT rule counted the 5678 packets, which went through FORWARD instead of INPUT:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>port 8081 -&gt; 000\nport 5678 -&gt; 200\n    4   240 DNAT       6    --  !docker0 *       0.0.0.0\/0            0.0.0.0\/0            tcp dpt:5678 to:172.17.0.2:5678<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Docker backend<\/th><th>UFW on a published port<\/th><th>DOCKER-USER<\/th><th>What to use<\/th><\/tr><\/thead><tbody><tr><td>iptables (default)<\/td><td>ufw deny and ufw route deny: port stays open<\/td><td>Exists; FORWARD jumps to it first<\/td><td>-p 127.0.0.1:PORT:PORT; DOCKER-USER with &#8211;ctorigdstport for a port that must stay public<\/td><\/tr><tr><td>nftables (Docker 29)<\/td><td>deny (routed) blocks the port and container outbound<\/td><td>Not used by Docker<\/td><td>-p 127.0.0.1:PORT:PORT; ufw route allow to the container for a public port<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\"><strong>The fix: loopback for the app or for the published port<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For an agent that runs on the host, bind the app itself to 127.0.0.1, as <code>N8N_LISTEN_ADDRESS<\/code> and <code>gateway.bind<\/code> do above. For an agent in a container, restrict the host side of the publish flag, <code>-p 127.0.0.1:PORT:PORT<\/code>, and let the app inside listen the way the container needs; the OpenClaw case shows that loopback inside the container leaves nothing answering. With <code>-p 127.0.0.1:5678:5678<\/code>, docker-proxy binds 127.0.0.1 alone:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker ps\n127.0.0.1:5678-&gt;5678\/tcp\nLISTEN 0 4096  127.0.0.1:5678  0.0.0.0:*  users:((\"docker-proxy\",pid=25308,fd=9))\n# from the second machine, UFW active\n5678\/tcp filtered rrac\n# from the second machine, UFW off\n5678\/tcp closed rrac\non the host:              {\"status\":\"ok\"} 200<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Docker 29.9.2 also adds a raw-table drop for every container address, so a neighbor that routed the container subnet through the host timed out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:14px\"><strong>nftables backend: UFW&#8217;s routed policy decides<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker 29 can run an nftables backend: add <code>\"firewall-backend\": \"nftables\"<\/code> to the daemon config, <span class=\"highlighted\">\/etc\/docker\/daemon.json<\/span>, and restart dockerd; the docs call it experimental since 29.0.0, though 29.9.2 needed no experimental flag and printed no warning. Docker does not switch on forwarding itself in this mode, and dockerd refused to start while <code>net.ipv4.ip_forward<\/code> was 0:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>failed to start daemon: [...] IPv4 forwarding is disabled: [...] set sysctl net.ipv4.ip_forward=1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Docker does not use DOCKER-USER here. On a host switched from the iptables backend with a daemon restart, the old chain and the FORWARD jump to it were still there, empty and no longer managed by Docker:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Firewall Backend: nftables\n$ iptables -S DOCKER-USER\n-N DOCKER-USER<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Before switching, delete any <code>ufw deny<\/code> or <code>ufw route deny<\/code> rules you added for published ports (<code>ufw status numbered<\/code>, then <code>ufw delete<\/code> with the number): a leftover route deny above a later route allow keeps the port closed. With <code>deny (routed)<\/code> the published port and the container&#8217;s outbound traffic were both blocked; a <code>ufw route allow<\/code> to the container&#8217;s address, which <code>docker inspect<\/code> shows and which can change when the container is recreated, restored inbound only:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Default: deny (incoming), allow (outgoing), deny (routed)\nto 198.51.100.10:5678 : 000          # published port blocked\ncontainer outbound    : FAILED\n$ ufw route allow proto tcp from any to 172.17.0.2 port 5678\nto 198.51.100.10:5678 : 200          # inbound restored\ncontainer outbound    : FAILED        # still blocked<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><a href=\"https:\/\/docs.docker.com\/engine\/network\/firewall-nftables\/\" target=\"_blank\" rel=\"noopener\">Docker nftables docs<\/a><\/strong> give the cause: a FORWARD chain whose policy is DROP, which is what UFW&#8217;s routed deny sets, discards traffic Docker&#8217;s own rules have already let through. Rules of your own belong in a separate nftables table with a forward hook; a drop there blocked the published port in the lab.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"800\" src=\"https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-docker-backends.webp\" alt=\"Two columns comparing a published port on Docker's iptables backend, where ufw deny leaves it open and the fix is publishing to 127.0.0.1 or a DOCKER-USER ctorigdstport rule, against the nftables backend, where ufw deny routed blocks the port and container outbound and ufw route allow restores inbound\" class=\"wp-image-3022\" srcset=\"https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-docker-backends.webp 1200w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-docker-backends-300x200.webp 300w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-docker-backends-1024x683.webp 1024w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-docker-backends-450x300.webp 450w, https:\/\/hostry.com\/blog\/wp-content\/uploads\/2026\/11\/ai-agent-exposed-to-internet-vps-docker-backends-768x512.webp 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Put nginx basic auth in front of n8n and keep the webhooks public<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the agent is on loopback, the only thing that should answer the internet is a reverse proxy. With n8n on <code>127.0.0.1:5678<\/code> and nginx basic auth on <code>\/<\/code>, the public locations are the two webhook prefixes. <code>\/webhook\/<\/code> is the production path, registered when you publish a workflow; n8n registers <code>\/webhook-test\/<\/code> only after you select Listen for Test Event or Execute workflow in the editor, so it needs to be public only while you build and test.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create the password file with <code>sudo apt install apache2-utils<\/code> and <code>sudo htpasswd -c -B \/etc\/nginx\/htpasswd-n8n admin<\/code>. The <code>map<\/code> line goes in a <code>.conf<\/code> file under <span class=\"highlighted\">\/etc\/nginx\/conf.d\/<\/span>, which Ubuntu includes inside the http block, and the rest in a server block under \/etc\/nginx\/sites-available\/ linked into sites-enabled:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># in the http block\nmap $http_upgrade $connection_upgrade { default upgrade; '' close; }\n\n# in the server block for n8n.example.com (listen 443 ssl, certificate lines [...])\nproxy_http_version 1.1;\nproxy_set_header Host $host;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto $scheme;\n\n# everything (editor, \/rest\/, \/healthz, \/setup ...) needs the password\nlocation \/ {\n  auth_basic \"n8n\";\n  auth_basic_user_file \/etc\/nginx\/htpasswd-n8n;\n  proxy_set_header Host $host;\n  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n  proxy_set_header X-Forwarded-Proto $scheme;\n  proxy_set_header Upgrade $http_upgrade;\n  proxy_set_header Connection $connection_upgrade;\n  proxy_pass http:\/\/127.0.0.1:5678;\n}\n# public: production and test webhooks only\nlocation \/webhook\/      { proxy_pass http:\/\/127.0.0.1:5678; }\nlocation \/webhook-test\/ { proxy_pass http:\/\/127.0.0.1:5678; }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The three header lines repeat inside <code>location \/<\/code> on purpose: nginx passes server-level <code>proxy_set_header<\/code> lines only to a location that sets none of its own. Without them, n8n with <code>NODE_ENV=production<\/code> refused the editor&#8217;s push websocket:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Origin header does NOT match the expected origin. (Origin: \"https:\/\/n8n.example.com\" -&gt; \"n8n.example.com\", Expected: \"127.0.0.1:5678\" -&gt; \"127.0.0.1:5678\", Protocol: \"https\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">From the second machine with no credentials (traversal rows sent with <code>curl --path-as-is<\/code>):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Request (no credentials)<\/th><th>Through the proxy<\/th><\/tr><\/thead><tbody><tr><td>GET \/ (editor)<\/td><td>401<\/td><\/tr><tr><td>GET \/setup<\/td><td>401<\/td><\/tr><tr><td>GET \/rest\/settings<\/td><td>401<\/td><\/tr><tr><td>GET \/healthz<\/td><td>401<\/td><\/tr><tr><td>GET \/webhook\/..\/rest\/settings<\/td><td>401<\/td><\/tr><tr><td>GET \/webhook\/%2e%2e\/rest\/settings<\/td><td>401<\/td><\/tr><tr><td>GET \/webhook\/..%2frest\/settings<\/td><td>401<\/td><\/tr><tr><td>POST \/webhook\/lab-hook<\/td><td>200<\/td><\/tr><tr><td>POST \/webhook\/unknown<\/td><td>404<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">nginx normalizes <code>..<\/code> and the <code>%2e<\/code> and <code>%2f<\/code> escapes before it matches a location, so the public prefix does not open a path to the editor. Set <code>N8N_WEBHOOK_URL<\/code> to the public base and <code>N8N_PROXY_HOPS=1<\/code> so webhook URLs and client addresses are right behind the proxy; the older <code>WEBHOOK_URL<\/code> still works but logs a deprecation warning on 2.47.7. Add the <code>form<\/code>, <code>mcp<\/code> or <code>webhook-waiting<\/code> locations only if a workflow uses those nodes. The <strong><a href=\"https:\/\/docs.n8n.io\/deploy\/host-n8n\/configure-n8n\/basic-configuration\/use-environment-variables\/endpoints\" target=\"_blank\" rel=\"noopener\">n8n endpoints reference<\/a><\/strong> lists the form and waiting paths; the <code>mcp<\/code> prefix is in the 2.47.7 source but not on that page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set <code>NODE_ENV=production<\/code> too, which drops the <span class=\"highlighted\">stacktrace<\/span> field. With it unset, as a plain npm install leaves it, the 404 body for an unknown public webhook on 2.47.7 carries a stack trace with your install paths:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"code\":404,\"message\":\"The requested webhook \\\"POST unknown\\\" is not registered.\",\"hint\":\"The workflow must be active for a production URL [...]\",\"stacktrace\":\"ResponseError: [...] (\/opt\/n8n\/node_modules\/n8n\/src\/webhooks\/live-webhooks.ts:296:10) [...]\"}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">When a container port must stay public<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On the iptables backend, filter a port that has to answer the internet in DOCKER-USER: the FORWARD chain jumps there before Docker&#8217;s own rules run. DNAT has already rewritten the destination by then, so match the port the client dialed with <code>--ctorigdstport<\/code>, as the <strong><a href=\"https:\/\/docs.docker.com\/engine\/network\/firewall-iptables\/\" target=\"_blank\" rel=\"noopener\">Docker iptables docs<\/a><\/strong> show. With a container published as <code>-p 15678:5678<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ iptables -I DOCKER-USER -p tcp --dport 15678 -j DROP                      # 0 packets, still reachable\n$ iptables -I DOCKER-USER -p tcp -m conntrack --ctorigdstport 15678 -j DROP  # blocks it (matches the original port)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To let one client through, replace that DROP rule with the form below rather than adding a second rule. A plain <code>! -s<\/code> also blocked the allowed client, because <code>--ctorigdstport<\/code> matches the container&#8217;s replies too; <code>-i &lt;ext-if&gt;<\/code> and <code>--ctorigsrc<\/code> avoid that. <code>ip route get 1.1.1.1<\/code> names <code>&lt;ext-if&gt;<\/code> after <code>dev<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iptables -I DOCKER-USER -i &lt;ext-if&gt; -p tcp -m conntrack --ctorigdstport 15678 ! --ctorigsrc &lt;allowed&gt; -j DROP<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">What not to do is a blanket <code>-j DROP<\/code> in DOCKER-USER: it blocked inbound, but also cut the container&#8217;s own outbound and the traffic between containers, even with an ESTABLISHED,RELATED accept above it. An interface-scoped, state-matched rule keeps those working:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>                                                   inbound  outbound  container-to-container\n-j DROP                                            blocked  FAILED    FAILED\n-i &lt;ext-if&gt; -m conntrack --ctstate NEW -j DROP     blocked  ok        ok<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That NEW-only rule blocks new connections to every published port on the interface, a proxy container on 443 included, so put a RETURN for each public port above it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iptables -I DOCKER-USER -i &lt;ext-if&gt; -m conntrack --ctstate NEW -j DROP\niptables -I DOCKER-USER -i &lt;ext-if&gt; -p tcp -m conntrack --ctorigdstport 15678 -j RETURN\n# inbound peer -&gt; :15678 : 200 ; inbound peer -&gt; :8188 : 000 ; outbound ok ; c2c ok<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Rules added with <code>iptables<\/code> directly are gone after a reboot. A hook appended to <span class=\"highlighted\">\/etc\/ufw\/after.rules<\/span> is read again every time UFW starts, boot included, but on a running system it takes effect only after <code>ufw reload<\/code>, and the block must declare the ufw chain it uses; without that line, reload fails and leaves the firewall worse than before:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ufw reload\nERROR: problem running ufw-init\niptables-restore v1.8.10 (nf_tables): Chain 'ufw-user-forward' does not exist\n# ufw.conf now reads ENABLED=no, while the old rules stay loaded in the kernel:\n$ ufw reload\nFirewall not enabled (skipping reload)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After that failed reload <code>ufw status<\/code> still prints <code>active<\/code>, but the firewall is marked disabled and will not reload until you enable it again. A block that declares both chains reloaded cleanly and did not duplicate on a second reload; the allowed client got 200, any other 000, and 8188 still answered:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>*filter\n:ufw-user-forward - [0:0]\n:DOCKER-USER - [0:0]\n-A DOCKER-USER -i &lt;ext-if&gt; -p tcp -m conntrack --ctorigdstport 15678 ! --ctorigsrc &lt;allowed&gt; -j DROP\nCOMMIT<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Scanner paths in your access log, and why a 200 is not a leak<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A SANS diary from July 13, 2026, <strong><a href=\"https:\/\/isc.sans.edu\/diary\/33150\" target=\"_blank\" rel=\"noopener\">Someone Is Scanning for Your MCP Servers and AI Assistant Credentials<\/a><\/strong>, pulled 14 days of one host&#8217;s logs and found requests for paths such as <code>\/mcp<\/code>, <code>\/sse<\/code>, <code>\/.claude\/mcp.json<\/code>, <code>\/v1\/models<\/code> and <code>\/api\/tags<\/code>. Replaying that path list against the lab&#8217;s own services, with nothing beyond a plain MCP initialize call, showed why the status code alone misleads:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Path<\/th><th>Behind basic auth<\/th><th>Static nginx (bare IP)<\/th><th>n8n 2.47.7 direct<\/th><th>OpenClaw 2026.11.4 direct<\/th><\/tr><\/thead><tbody><tr><td>POST \/mcp<\/td><td>401<\/td><td>404<\/td><td>404<\/td><td>404<\/td><\/tr><tr><td>GET \/sse<\/td><td>401<\/td><td>404<\/td><td>200<\/td><td>200<\/td><\/tr><tr><td>GET \/.claude\/mcp.json<\/td><td>401<\/td><td>404<\/td><td>200<\/td><td>404<\/td><\/tr><tr><td>GET \/v1\/models<\/td><td>401<\/td><td>404<\/td><td>200<\/td><td>404<\/td><\/tr><tr><td>GET \/api\/tags<\/td><td>401<\/td><td>404<\/td><td>200<\/td><td>404<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">n8n answered 200 to most of those paths because it serves its 1708-byte editor page for any unknown GET, and OpenClaw answered 200 on <code>\/sse<\/code> with its Control UI HTML. Neither has those files. In a combined-format log the number after the status code is the response size, so a 200 of 1708 bytes (n8n 2.47.7) or 21699 bytes (OpenClaw 2026.11.4) on these paths matches one of those pages sent uncompressed, while a body of another size deserves a closer look.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>\/api\/tags<\/code> is Ollama&#8217;s model list. Ollama was not run in the lab; its FAQ says the server binds 127.0.0.1 by default and that <code>OLLAMA_HOST<\/code> changes the bind address, and it documents no authentication for the API. A JSON answer on <code>\/api\/tags<\/code> from outside therefore means anyone can list your models and call the API: set the bind address back to 127.0.0.1, or put Ollama behind the same nginx basic auth.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One grep pulls the recon requests out of an nginx combined log, and the second keeps only the 2xx responses worth inspecting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ grep -E '\"[A-Z]+ \/(mcp|sse|v1\/models|api\/tags|\\.(claude|cursor|vscode)\/)[^ ]* HTTP\/' access.log | wc -l\n17\n# the line to worry about: any 2xx on those paths?\n$ grep -E '\"[A-Z]+ \/(mcp|sse|v1\/models|api\/tags|\\.(claude|cursor|vscode)\/)[^ ]* HTTP\/[0-9.]+\" 2[0-9][0-9] ' access.log | wc -l\n0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The replay sent eight SANS paths (these five plus <code>\/.cursor\/mcp.json<\/code>, <code>\/.vscode\/mcp.json<\/code> and a HEAD request for Claude&#8217;s credentials file) to each nginx site, and the first pattern found all 16 lines in a 46-line log plus the lab&#8217;s earlier <code>\/mcp\/x<\/code> request; nothing else matched. Behind the basic-auth setup the second count was zero; if yours returns lines, check their size and content type as above. For rotated logs, <code>zgrep -E<\/code> takes the same pattern.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">If a firewall rule locks you out<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If SSH stops answering after a rule change, the panel&#8217;s VNC console still reaches the server; remove the rule you added last from there. Hostry&#8217;s panel firewall sits outside the server as a second layer, so a Docker-published port that slips past UFW still meets it, and a rule set there that admits only SSH and the proxy would have stopped the 8188 case above. Both live in the <strong><a href=\"https:\/\/hostry.com\/products\/vps\/\">Hostry Linux VPS panel<\/a><\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the four steps again after any change to a container, a bind address or a firewall rule, since each of those can reopen what you closed. Every layer checked here needs root, which a Hostry Linux VPS gives you from $6.00\/mo; the entry plan has one vCPU, a gigabyte of RAM and NVMe storage, and larger plans reach 32 GB RAM.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>On a lab host where UFW allowed only 22, 80 and 443, a Docker-published port still answered from a second machine. Lab runs of n8n 2.47.7 and OpenClaw&#8230;<\/p>\n","protected":false},"author":6,"featured_media":3030,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,78,127],"tags":[],"class_list":["post-3032","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-virtual-private-server","category-apps","category-security"],"read_time":13,"_links":{"self":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts\/3032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/comments?post=3032"}],"version-history":[{"count":1,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts\/3032\/revisions"}],"predecessor-version":[{"id":3038,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts\/3032\/revisions\/3038"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/media\/3030"}],"wp:attachment":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/media?parent=3032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/categories?post=3032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/tags?post=3032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}