Deploying Go web applications with Apache

Kaveh Shahbazian picture Kaveh Shahbazian · Apr 5, 2012 · Viewed 27k times · Source

I can not find a mod_go for deploying Go web applications. Is there any other way to run web applications in Go with an Apache web server (or even IIS)?

Update: Now after doing Go full time for nearly a year; doing this (Go with Apache) is nullifying the very purpose of Go (Performance in terms of being highly concurrent). And I'm using nginx as a reverse proxy for http/https and having my Go backends behind it nicely. Though you have to change your mindset on webapps a bit when using Go.

Answer

Mostafa picture Mostafa · Apr 5, 2012

There's no mod_go. (At least I've not heard of such a thing.)

A go web app by itself is a capable web server. You can listen to port 80 in your app and then directly run it on your server. Trust me: it really works!

But if you are not doing that (for reasons such as having other virtual servers on the same machine, load balancing, etc.), you can use a HTTP server such as nginx or Apache as a HTTP proxy in front of your Go app. I use nginx and it's great. Here's an outdated but still very useful guide on how to do that with nginx. I haven't done it with Apache, but this should help.

I recommend your Go web app by itself or nginx as a HTTP proxy.