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.
For more information about the port numbers to make available, see TCP and UDP ports used by Apple software products.