# Go vs Apache, or both?

**URL:** <https://forum.golangbridge.org/t/go-vs-apache-or-both/3415>\
**Category:** Technical Discussion\
**Created:** [September 12, 2016, 11:41pm UTC](https://forum.golangbridge.org/t/go-vs-apache-or-both/3415 "2016-09-12T23:41:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raelon\_Masters](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/raelon_masters/32/2411_2.png) [@Raelon\_Masters](https://forum.golangbridge.org/u/Raelon_Masters)\
**Post date:** [September 12, 2016, 11:41pm UTC](https://forum.golangbridge.org/t/go-vs-apache-or-both/3415/1 "2016-09-12T23:41:54Z")

</div>

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.

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![christophberger](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/christophberger/32/11391_2.png) [@christophberger](https://forum.golangbridge.org/u/christophberger)\
**Post date:** [September 13, 2016, 4:37am UTC](https://forum.golangbridge.org/t/go-vs-apache-or-both/3415/2 "2016-09-13T04:37:39Z")

</div>

> [@Raelon\_Masters](#):
>
> running a go server alongside my servers current Apache install.

It is certainly possible. I see these options:

- 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](http://mydomain.com)” routes to Apache and “[discord.mydomain.com](http://discord.mydomain.com)” routes to the Go server.)

---

<div class="post-metadata">

**Author:** ![geosoft1](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/geosoft1/32/2151_2.png) [@geosoft1](https://forum.golangbridge.org/u/geosoft1)\
**Post date:** [September 13, 2016, 8:11am UTC](https://forum.golangbridge.org/t/go-vs-apache-or-both/3415/3 "2016-09-13T08:11:33Z")

</div>

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`

```
<VirtualHost *:80>
        ServerAdmin admin@example.com

        ServerName goapp.example.com

        Redirect "/" "http://goapp.example.com:8081"
</VirtualHost>

```

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`  
😊

---

<div class="post-metadata">

**Author:** ![ikrabbe](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/ikrabbe/32/2407_2.png) [@ikrabbe](https://forum.golangbridge.org/u/ikrabbe)\
**Post date:** [September 13, 2016, 8:22am UTC](https://forum.golangbridge.org/t/go-vs-apache-or-both/3415/4 "2016-09-13T08:22:10Z")

</div>

As a proxy solution, that is far more flexible than working with redirect I strongly recommend to use nginx or haproxy, but apache.

```
location /godoc {
    proxy_pass http://localhost:6060/;
} # for nginx
```

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [December 12, 2016, 8:22am UTC](https://forum.golangbridge.org/t/go-vs-apache-or-both/3415/5 "2016-12-12T08:22:14Z")

</div>

Closed on December 12, 2016, 8:22am UTC

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