How to Safely Host Public Servers on a UniFi Network

Management Summary
A public web server makes a website or service available over the internet. In a UniFi home or business network, a separate area called a DMZ keeps that exposed service apart from private computers and other devices. Restricting connections between the areas reduces the chance that a problem on the public server spreads into the private network. The separation still needs room for necessary administration and updates, alongside protected access and recoverable backups.
Contents
A public Raspberry Pi web server should have only limited access to private systems. A VLAN is a separate logical network carried over the network equipment. A DMZ is the isolated area intended for publicly reachable services. Firewall rules between that area and private devices can limit an attacker’s access after the server is taken over. A VLAN name or a working port forward alone does not prove isolation.
Define the permitted paths first
- Internet → server: only the public service, for example TCP 443.
- Administration → server: only selected management hosts and necessary ports, such as SSH.
- Server → internet: required updates and service dependencies, with broader egress treated as a deliberate trade-off.
- Server → private systems: no new connections except documented, narrowly scoped dependencies.
The reply to an allowed administration session is different from a new server-initiated connection. Both directions must be represented in the effective rules.

Prepare the network boundary
The server VLAN must actually reach the intended gateway through the switch-port configuration. Traffic between hosts in the same subnet may never traverse that gateway. Private networks include all protected destinations, including any IPv6 prefixes and VPN networks; an RFC1918 IPv4 address group alone does not cover that scope.
Legacy rules: direction and state matter
In the legacy interface, LAN IN applies to traffic arriving from a local network and routed onwards. LAN LOCAL applies to the gateway itself, the router connecting the networks. Established means traffic belonging to an existing connection; Related covers traffic associated with an existing connection. A narrowly scoped allowance for these states, placed above the DMZ-to-private block, preserves replies to authorized sessions. Existing rules and invalid-state handling still need review. Two example rules are not a complete firewall configuration.
Zone-based rules: verify the return policy
UniFi zones group interfaces and networks. The server network belongs in the intended DMZ zone; private networks belong in their protected zones. Ubiquiti’s current documentation lists version-dependent paths such as Settings → Zones and Settings → Policy Table. The zone matrix exposes each direction.
An allow policy for management traffic can use Auto Allow Return Traffic. This creates a return policy; it is not a guarantee that an overriding custom block cannot defeat it. The reverse direction must permit the relevant established/related replies before a broader block, while new DMZ-to-private connections remain blocked. Both IPv4 and IPv6 require the intended scope.
The Gateway zone is separate. DNS translates names into addresses; DHCP assigns network settings to devices. Allowing these necessary router services does not justify access to the router’s administration page. A blanket gateway block can instead break address assignment or name resolution. A private DNS service on a separate LAN server needs its own narrowly scoped exception.
Publish the required service
For an IPv4 port forward, the selected WAN, incoming port, destination address, destination port and protocol must match the actual service. A stable server address avoids forwarding to the wrong host after a lease change. UniFi generates associated policies, but the effective ordering still needs checking.
NAT translates network addresses. With double NAT, two routers perform that translation in succession. With carrier-grade NAT, the internet provider shares public addresses between customers. Either can prevent inbound access even when the UniFi port forward is correct. A UniFi rule cannot configure the provider’s upstream translation. IPv6 needs a separate routing and firewall review; an IPv4 forward does not define every public access path.
Test the boundary, not only the homepage
A test from an external network should reach the intended HTTPS service and fail on unapproved services. A management host should establish a fresh authorized session and receive replies. New connections from the DMZ to a known listening private service should fail, with a corresponding firewall log or counter where available. A failed ping alone may merely reflect a host rejecting ICMP.
Application patches, authentication, host firewall rules and recoverable backups remain necessary. A compromised server can misuse every explicitly permitted dependency.
Questions and answers
Does a reverse-proxy exception invalidate every DMZ rule?
No. A reverse proxy accepts requests and forwards them to a backend, the server providing the actual application. An exception for that specific backend makes it reachable without automatically opening the entire private network. The destination address, port and credentials still need explicit review.
Why does gateway DNS still work?
A DMZ-to-Internal rule does not necessarily cover the Gateway zone. The actual DNS destination and applicable rule determine the result.


