Arama Yap Mesaj Submit
Request a Callback
+90
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro

Contact Us

Location Halkali merkez neighborhood fatih st ozgur apt no 46 , Kucukcekmece , Istanbul , 34303 , TR
Docker Port Security: 0.0.0.0 vs 127.0.0.1, Nginx Reverse Proxy and SSL
Docker Security, Nginx, Reverse Proxy and Ubuntu 24.04

Docker Port Security on Ubuntu 24.04: 0.0.0.0 vs 127.0.0.1, Nginx Reverse Proxy and SSL

This guide isolates one of the most important security patterns from our real Ubuntu 24.04 self-hosted AI stack: keep application ports on 127.0.0.1 instead of publishing them on 0.0.0.0, then provide public access through Nginx and HTTPS. We applied this to Portainer 9443, Ollama 11434, Open WebUI 3000 and n8n 5678.

Docker port security0.0.0.0127.0.0.1Docker localhost bindDocker publish portNginx reverse proxyDocker UFWPortainer securityOllama securityn8n securityOpen WebUI securityLet's EncryptUbuntu 24.04EKA Sunucu
Ollama / Qwen3 / Open WebUI / Ubuntu 24.04
Internet :443
   ↓
Nginx + TLS
   ├─ 127.0.0.1:9443  → Portainer
   ├─ 127.0.0.1:3000  → Open WebUI
   ├─ 127.0.0.1:5678  → n8n
   └─ Ollama 127.0.0.1:11434 + private Docker network
Ollama0.32.6Open WebUI0.11.0 test
13real WebP screenshots
3TR · EN · DE content
443public HTTPS
127.0.0.1AI service loopback
010.0.0.0 vs 127.0.0.1
02localhost-only Docker ports
03Nginx reverse proxy + WebSocket
04HTTPS + renewal audit
00
Table of contents

Docker port security and Nginx reverse proxy steps

  1. 01What is the difference between Docker port binding on 0.0.0.0 and 127.0.0.1?
  2. 02How did we separate Portainer, Ollama, Open WebUI and n8n ports?
  3. 03Read public and localhost-only bindings from docker ps
  4. 04Use ss to confirm which addresses are actually listening
  5. 05Keep the application port local and publish it through an Nginx reverse proxy
  6. 06Preserve WebSocket Upgrade headers for n8n and Open WebUI
  7. 07Verify the Nginx domain with a real HTTPS request after Let's Encrypt setup
  8. 08Do not rely only on UFW for Docker published ports
  9. 09Which public/private pattern did we use for Portainer, Open WebUI, n8n and Ollama?
  10. 10How do you fix a Docker port that was accidentally published on 0.0.0.0?
  11. 11Run one final Docker, Nginx, HTTPS and renewal audit before production
  12. 12Re-check port publishing after container upgrades
01
Core security difference

What is the difference between Docker port binding on 0.0.0.0 and 127.0.0.1?

A publish command such as -p 8080:80 without a host IP can bind the port on all Docker-host addresses by default. That can expose an administration or API port outside the host.

When you explicitly publish to 127.0.0.1, the published port is accessible only from the Docker host. This is the core host-port decision in our self-hosted AI stack.

Command 1
docker run -p 8080:80 nginx
Command 2
docker run -p 127.0.0.1:8080:80 nginx
02
Real tested layout

How did we separate Portainer, Ollama, Open WebUI and n8n ports?

In our real Ubuntu 24.04 stack, Portainer 9443, Ollama 11434, Open WebUI 3000 and n8n 5678 were bound only to 127.0.0.1 on the host. We did not publish those application ports directly to the Internet.

Web applications that needed public access were published through Nginx on ports 80/443. Ollama remained a backend API on localhost and the private Docker network.

Command 1
127.0.0.1:9443 → Portainer
Command 2
127.0.0.1:11434 → Ollama
Command 3
127.0.0.1:3000 → Open WebUI
Command 4
127.0.0.1:5678 → n8n
Command 5
0.0.0.0:80 / :443 → Nginx
03
First audit

Read public and localhost-only bindings from docker ps

The Ports column in docker ps is a fast security audit. 127.0.0.1:5678->5678/tcp means loopback-only binding. 0.0.0.0:5678->5678/tcp means the port is published on all IPv4 host interfaces.

Make this check routine for admin panels, databases, local LLM APIs and automation editors.

Command 1
docker ps --format 'table {{.Names}}\t{{.Ports}}'
04
Linux socket verification

Use ss to confirm which addresses are actually listening

In addition to Docker output, inspect Linux listening sockets. In our final design the application ports listen on 127.0.0.1 while Nginx exposes 80/443 on public interfaces.

Using both checks confirms that Docker publishing and the operating-system socket view match the intended architecture.

Command 1
ss -lntp | grep -E ':80|:443|:9443|:11434|:3000|:5678'
05
Public access layer

Keep the application port local and publish it through an Nginx reverse proxy

With the app listening on localhost, Nginx can accept public HTTPS traffic and forward it to a local upstream. Our n8n layout used proxy_pass http://127.0.0.1:5678; Open WebUI used the same pattern on 127.0.0.1:3000.

This model centralizes TLS, domains, access logs, rate limiting and optional authentication at one public entry layer.

Command 1
location / {
    proxy_pass http://127.0.0.1:5678;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}
06
WebSocket support

Preserve WebSocket Upgrade headers for n8n and Open WebUI

WebSocket Upgrade and Connection headers are hop-by-hop, so a reverse proxy must pass the necessary upgrade information explicitly. This matters for real-time web apps such as n8n and Open WebUI.

We used an Nginx map for connection_upgrade and forwarded HTTP/1.1, Upgrade and Connection headers inside the proxied location.

Command 1
map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}
Command 2
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
07
TLS layer

Verify the Nginx domain with a real HTTPS request after Let's Encrypt setup

A localhost-only app port needs a public domain layer when users must reach it. We installed certificates after validating Nginx configuration and then confirmed successful HTTPS responses.

certbot renew --dry-run is a practical way to test the renewal path without replacing the live certificate.

Command 1
nginx -t
Command 2
curl -I https://n8n.ekasunucu.com
Command 3
certbot renew --dry-run
08
Firewall detail

Do not rely only on UFW for Docker published ports

Docker manages firewall and NAT rules for published ports. Docker's official documentation warns that a port published without a host IP may be reachable externally and that Docker's iptables handling can bypass expectations based only on UFW configuration.

Make the primary decision in the Docker publish expression itself: -p 127.0.0.1:HOST:CONTAINER. Treat the host firewall as an additional layer.

Command 1
-p 5678:5678
Command 2
-p 127.0.0.1:5678:5678
09
Service-specific pattern

Which public/private pattern did we use for Portainer, Open WebUI, n8n and Ollama?

Portainer, Open WebUI and n8n need browser access, so we used localhost application ports plus Nginx domain HTTPS. Public users see only the TLS entry point.

Ollama remained a backend API. The host uses 127.0.0.1:11434 and Docker services use ollama:11434; no public 11434 listener is required.

Command 1
portainer.ekasunucu.com → Nginx → 127.0.0.1:9443
Command 2
openwebui.ekasunucu.com → Nginx → 127.0.0.1:3000
Command 3
n8n.ekasunucu.com → Nginx → 127.0.0.1:5678
Command 4
Ollama → 127.0.0.1:11434 + eka-ai private network
10
Fix an existing deployment

How do you fix a Docker port that was accidentally published on 0.0.0.0?

A container's published port mapping is not normally changed in place like a network attachment. Recreate the container with the same volumes, environment and network settings, but use a localhost-only -p mapping.

Capture the existing inspect output first. Named volumes can preserve application data independently of the container lifecycle, but take a backup or snapshot before production recreation.

Command 1
docker inspect n8n > /root/n8n-before-port-fix.json
Command 2
docker rm -f n8n
Command 3
docker run -d --name n8n --restart=always --env-file /root/n8n.env -p 127.0.0.1:5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n:latest
11
Final audit

Run one final Docker, Nginx, HTTPS and renewal audit before production

Check docker ps for mappings, ss for actual sockets, nginx -t for configuration, a real HTTPS request for the public endpoint and Certbot dry-run for renewal.

The expected design is: application ports on 127.0.0.1, public web entry only through Nginx 80/443, successful HTTPS and a working renewal test.

Command 1
docker ps --format 'table {{.Names}}\t{{.Ports}}'
Command 2
ss -lntp | grep -E ':80|:443|:9443|:11434|:3000|:5678'
Command 3
nginx -t
Command 4
curl -I https://n8n.ekasunucu.com
Command 5
certbot renew --dry-run
12
Continuous security

Re-check port publishing after container upgrades

If old docker run parameters are lost during an image update, a recreated service may accidentally be published on 0.0.0.0. Make port-mapping verification a mandatory deployment step.

Verifying bindings, Nginx upstreams, HTTPS health and private Docker networking together reduces accidental public exposure in self-hosted services.

Command 1
docker ps --format 'table {{.Names}}\t{{.Ports}}'
Command 2
ss -lntp
Command 3
docker network inspect eka-ai
Command 4
nginx -t
Production checklist

Docker port and reverse-proxy security checklist

Avoid publishing application ports on 0.0.0.0 unless required.
Keep backend services on 127.0.0.1 or a private Docker network.
Publish public web services through an HTTPS reverse proxy.
Verify actual host bindings with docker ps and ss.
Forward WebSocket Upgrade/Connection headers where needed.
Do not rely only on UFW for Docker published ports.
Back up volume, environment, network and restart settings before container recreation.
Run certificate renewal dry-runs regularly.
Re-check that image upgrades did not change ports back to 0.0.0.0.
Keep backend APIs such as Ollama private when public exposure is unnecessary.
R
Official sources

Official Docker and Nginx resources

+
EKA Sunucu

Related EKA Sunucu Docker, Portainer, Ollama, Open WebUI and n8n guides

?
FAQ

Frequently asked questions about Docker port security

What does docker -p 8080:80 do?

Without a host IP, Docker can publish the port on all host addresses by default.

What changes with -p 127.0.0.1:8080:80?

The published port is restricted to the Docker host loopback address.

What does 0.0.0.0 mean?

It generally represents all suitable IPv4 host interfaces for the listening or published port.

How do I check whether a Docker port is public?

Inspect the docker ps Ports column and verify listening sockets with ss -lntp.

Should n8n port 5678 be public?

Not in this architecture; it stays on 127.0.0.1:5678 and Nginx provides HTTPS access.

Should Open WebUI port 3000 be public?

We kept it on localhost and published the domain through Nginx.

Should Ollama port 11434 be public?

No in this design; it uses 127.0.0.1 on the host and a private Docker network between containers.

How was Portainer 9443 protected?

The host binding was restricted to 127.0.0.1:9443 and domain access was proxied by Nginx.

What does an Nginx reverse proxy do here?

It accepts public domain/TLS traffic and forwards it to a backend application listening on localhost.

Why are extra WebSocket headers needed?

Upgrade and Connection information must be passed explicitly by the reverse proxy.

Will UFW always block a Docker published port?

Do not rely on UFW alone; Docker manages its own firewall/NAT rules, so choose the host bind address correctly.

Can I change a published port mapping on a running container?

Normally recreate the container with the correct volumes, environment, networks and publish mapping.

How do I test SSL renewal?

Run certbot renew --dry-run.

What should I verify after updates?

Re-check docker ps, ss, Nginx configuration, HTTPS health, private networks and certificate renewal.

EKA YAZILIM VE BİLİŞİM SİSTEMLERİ

Need a Linux VPS for secure self-hosted Docker services?

Run Portainer, Ollama, Open WebUI, n8n and other Docker services behind Nginx and HTTPS on your own EKA Sunucu Linux VPS.

Updated: 10.08.2026
View Linux VPS PlansLinux & VPS Guides
Top