Please see these diagrams explaining the two possible options:
https://www.chirpstack.io/docs/architecture.html