一个域上有多个应用程序

SITUATION

Let's say I have a domain example.com. I want to write a main application using Node.js and some components using Golang.

QUESTIONS

Is it possible to run api.example.com/first using Node.js and api.example.com/second using Golang? Or is it possible to write run different applications on different subdomains?

  • I'm not talking about executing Golang programmes through Node.js

Best way I can think of is to:

  1. Setup a reverse proxy such as Nginx
  2. Run it on port 80 and 443 (for HTTPS)
  3. Run you applications on different ports and bind to loopback IP address (127.0.0.1 usually)
  4. Define your reverse proxy routes in Nginx to match your applications

Check out this tutorial on how to do the previous: https://flaviocopes.com/go-nginx-reverse-proxy/