Problem trying to run Golang with Apache2 as a reverse proxy server

I have been trying without success for the past few days to get Golang to work on an Apache2 server running Ubuntu 14.04

I believe Localhost Golang applications can be uploaded to an Apache2 server running as a reverse proxy.

I have Golang installed locally and created numerous Golang applications.

I have managed to get http://localhost:8080 to run the Golang http.go application but cannot progress pass this point.

####Tutorials followed

  1. http://grokbase.com/t/gg/golang-nuts/1451k6w0a6/go-nuts-run-go-code-with-apache
  2. https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
  3. http://www.jeffreybolle.com/blog/create-a-web-app-using-google-go
  4. http://www.jeffreybolle.com/blog/run-google-go-web-apps-behind-apache

Has anyone managed to get Golang running on Apache2? If so I would be grateful for a link to a tutorial.

Hi John,

Can you also get your application running on the remote server on port 8080?

I am unable to get the remote Apache2 server on port 8080 to work. I think this is because a reverse proxy server is required.

I have read that once the reverse proxy is working, Localhost compiled Golang source code can be uploaded to the remote server.

It is not necessary to install Golang on the remote server.

If your program runs on the remote server, you should be able to access it via the server’s IP (e.g. http://192.168.0.1:8080) unless the server configuration blocks that port.

I managed to set up Apache2 to proxy to a golang app by doing the following:

  • Install the proxy and proxy_http modules (e.g. sudo a2enmod proxy on an Ubuntu server)
  • Add the virtual host configuration (see below)
  • Restart apache2

The VirtualHost settings:

<VirtualHost *:80>
  ServerName www.example.com
  ProxyPass / http://127.0.0.1:8080/
</VirtualHost>

@fretburner

Many thanks for your script.

It is not doing exactly what is required but at least it is producing output. This is far better than what I had before which was a blank screen and no access or error logs.

It is rather later here and have had enough for one day. I hope to try again tomorrow.

No worries. If you want, just let me know what it is you’re trying to achieve and I can try that out on my setup and see if I can figure it out :slight_smile:

1 Like

I tied myself in knots with the Apache2 Reverse Proxy. I managed to get it to reverse proxy to localhost and to my other sites but do not understand how to use the facility :frowning:

I installed Golang on the remote server and now the sites are calling a compiled Golang executable:

Site-001

Site-002

Site-003

Site-004

Delighted to say the http://tools.Pingdom.com/fpt speed tests are exceptional for a first attempt, about 50ms!!!

Google Analytics was taking nearly four times as long to load than the rest of the page so I have temporarily disabled until I can find why it is so slow.

…to be continued

…to be continued

I managed to solve the multiple Apache2 Reverse Prosy problem by using CaddyServer and they utilise the Free Automatic Https Protocol which was recently released late December 2015.

Golang is interesting but for me it is hard-work :frowning: According to a blog, it takes about three-months before it starts to make sense and then it becomes productive.

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