0

Let's say I have the following simple Go web app:

package main

import (
    "fmt"
    "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello World")
}

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
}

I have a website which is hosted by my university (www.univ.edu/me) and currently I have a wiki setup under www.univ.edu/me/wiki and it works fine. My question is how I can deploy the above Go app there so it can be accessed through www.univ.edu/me/mygoapp?

I have found some solutions but they all appear to require root privileges. In my case, I don't have root access and I'm not able to modify the configuration of server, which most likely is Apache.

Update: Thanks for your replies. It appears that in my case, the Apache server is on a separate machine than the one which physically hosts my website files. The machine/IP that has the Apache, refuses ssh connections so there's no direct way to check the server's configuration.

3
  • Is Go even installed? Commented May 28, 2013 at 19:22
  • Yes, it is installed in my home folder. Commented May 28, 2013 at 19:25
  • 2
    do you have access to fcgi? is so, you can write your go server to that spec with golang.org/pkg/net/http/fcgi and deploy it as a binary. I've done this in the past with bluehost. Commented May 28, 2013 at 20:18

2 Answers 2

2

Take a look at Apaches mod_proxy. It offers proxying another HTTP Server when certain virtual directories are requested:

<Location /goapp/>
    ProxyPass http://localhost:8080/
</Location>

You may need to do additional changes to your Apache config to make sure the request gets passed through properly.

Sign up to request clarification or add additional context in comments.

Comments

1

If you have write access to the .htaccess file in your MediaWiki installation you may be able to add:

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

This is dependant on the global Apache configuration, as mod_proxy is often disabled or restricted on premises like Universities, but it's worth a try.

See http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass and http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse for more details.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.