Run Multiple Go WebApps in same server

Hi everyone, I have a Linux server where I expect to host many Go WebApps.By now it’s running one and everything is fine. But now, I noticed that I will not be able to run others WebApps because the port 80 will be busy with the first website, how can I handle it? that’s one thing.

The other is, how can I handle multiple URL’s in the same server. How to redirect to certain webapp depending of the URL requested? is it possible? I was thinking in a reverse proxy as Nginx but then I have the problem with the port 80.
Thank you very much!

Yes, the approach is to use a reverse proxy that redirect to certain webapp based on hostname or path

try caddy ( I’m using it with a couchdb, a nodejs webapp and 2 websites at the same time (with https and redirections included)


So as the other poster said, use a reverse proxy (definitely try caddy first, I’ve used it and can recommend). This will serve on port 80/443, and then proxy requests on that port through to your backends on ports like 4000-5000 say, of which you can have as many as the server can handle. By default caddy will serve on port 443 and redirect 80 to that.

Then you need to run your go services higher ports, and proxy requests for certain domains over to them with a short caddy file per server something like this (a complete config): {
} {

  root /srv/
  log /srv/
  proxy / :4000 {
     except /assets /robots.txt /favicon.ico

Make sure you block higher ports on your firewall, or those would also be exposed directly. You could also use nginx, but https would be more complex.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.