Hello,
I am getting ready to start developing a discord bot, and am thinking about using golang as discord has a go package with all the api hooks etc… I have been looking on google and YouTube for some information regarding running a go server alongside my servers current Apache install. So far i haven’t come up with anything.
Keep in mind I’ve only just now started looking at go so whether or not this is possible or even recommended I have no idea.
Write your Go server just as you would do when there was no Apache running. Have it listen on a port other than 80. Then configure Apache as an HTTP proxy for the Go server.
Write your Go server as a FastCGI service for Apache.
Use different (sub-)domains for Apache and for the Go server. (E.g., “mydomain.com” routes to Apache and “discord.mydomain.com” routes to the Go server.)
a short example. let say you have example.com domain served by apache on port 80. probably you also have a bind server so you can add in the db.example.com file a CNAME (or A) record like
goapp IN CNAME example.com.
so, your apache will serve now goapp.example.com an also example.com both on port 80. next, make a virtual host in /etc/apache/sites-available
enable, this in with a symbolic link in /etc/apache/sites-enabled, compile with run your go application on port 8081. you can run your go application with no root rights.
now, if you will access goapp.example.com you will be redirect to goapp.example.com:8081