I'm a Go newbie and I'm stuck trying to figure out how to deploy my apps on a dedicated server.
When I worked with PHP I used the standard setup:
But I'm confused as to how I'm supposed to deploy my Go apps.
I know I can run a single app on port :80
but how do I run multiple apps?
Is this the general idea:
Or should I be using something like this:
Can someone clarify the way most Go developers deploy their apps? Thanks!
I'd highly recommend going with Caddy. You can set up you server with all the apps on different ports (esp. higher ports i.e. 1024 and up, so they don't need to be root), and then use proxy
directives to forward traffic to your apps and such. As a bonus, you also then get free Let's Encrypt certificate support!
https://caddyserver.com/docs/proxy for more on the proxy
directive
You might want to look a Traefik (https://traefik.io/), a go based web proxy
If you need multiple apps to serve HTTP requests, you should definitely consider using Nginx as a reverse proxy. You can forward all requests on a given route, say /api to one service and /ui to a second service, provided they are bound to different ports.