How macOS Server uses services and ports
If your server (the computer where you installed macOS Server) connects to the internet through a cable router, DSL router, or other network router, you can configure port forwarding (or port mapping) to allow access to some services from the internet while protecting other services and other computers on your network. Determine the port numbers for the services you want to expose on the internet. Configure your router to forward only those ports to your server’s IP address.
Some internet routers may require you to specify TCP or UDP for each port. For specific information about how to configure port forwarding on your router, see its documentation.
If your intranet has a separate firewall device, and you want to allow access to some services outside your intranet, ask the firewall administrator to open the firewall for the communications ports and protocols that your services use.