Sredny M Casanova
Sredny M Casanova

Reputation: 5053

Using Proxy server to switch between Golang Applications

I have a server with CentOS, and there I will have at least 4 Golang applications running, every one of them is a different site that I should be able to access in the browser with domain/subdomains as follows:

So, I need to configure some kind of software that redirects the requests to the correct Golang process. Every site will be running in a different port, so for example if someone calls dev00.mysite.com I should be able to send that request to the process of dev00 site (this is for development porpouses, not production). So, here I'm starting to believe that I need Nginx or Caddy as I read, but I have no experience with none of them. Can someone confirm that this is the way to fix that problem? and where can I find some example of configuration of any of that servers redirecting to Golang applications?

And, in the future if a have a lot (really a lot) of domains running in the same server, which of that servers is better? who is better with high load?

Upvotes: 0

Views: 851

Answers (1)

Laurence
Laurence

Reputation: 781

Yes, Nginx can solve your problem:

  1. Start a web server using the standard library of Go or Caddy.
  2. Redirect request to Go application using Nginx:

Example Nginx configuration:

server {
    listen 80;
    server_name dev00.mysite.com;
    ...

    location / {
        proxy_pass http://localhost:8000;
        ...
    }
}

server {
    listen 80;
    server_name dev01.mysite.com;
    ...

    location / {
        proxy_pass http://localhost:8001;
        ...
    }
}

Upvotes: 2

Related Questions