# 502 bad gateway apache proxy multi site config

**URL:** https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660
**Category:** Self-hosting
**Created:** [July 5, 2018, 9:28pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660 "2018-07-05T21:28:02Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 7, 2018, 12:32pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/21 "2018-07-07T12:32:36Z")

</div>

nope all is good with proxy modules

---

<div class="post-metadata">

### Author: ![Cameron\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cameron_d/32/97535_2.png) [@Cameron\_D](https://meta.discourse.org/u/Cameron_D)
#### Post date: [July 7, 2018, 1:21pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/22 "2018-07-07T13:21:22Z")

</div>

If you are able to access it via the direct port then the problem is most likely with your Apache proxy config. That is where I’d be looking.

You should definitely be using `localhost` or `127.0.0.1` instead of `0.0.0.0`, because `0.0.0.0` is just a generic all-interfaces shortcut, so who knows where that traffic is going to head… It was probably luck that it was working with that address earlier.

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 7, 2018, 1:25pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/23 "2018-07-07T13:25:10Z")

</div>

Thanks for the reply. I have tried like 5-6 directives in the domain’s virtualhost in httpd.conf

Here are they:  
Timeout 2400  
ProxyTimeout 2400  
ProxyBadHeader Ignore  
ProxyPass / [http://0.0.0.0:8080/](http://0.0.0.0:8080/) retry=1 acquire=3000 timeout=600 Keepalive=On

But none of them work

---

<div class="post-metadata">

### Author: ![Cameron\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cameron_d/32/97535_2.png) [@Cameron\_D](https://meta.discourse.org/u/Cameron_D)
#### Post date: [July 7, 2018, 1:28pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/24 "2018-07-07T13:28:08Z")

</div>

SSH into the host and run a `curl http://0.0.0.0:8080`. Does that work? (Or `127.0.0.1`)  
If so then I’d quite happily say its something with the proxy directives. Unfortunately I’ve never used Apache as a reverse proxy so I can’t really help you out there.

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 7, 2018, 1:34pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/25 "2018-07-07T13:34:50Z")

</div>

`curl http://0.0.0.0:8080/ ` gives `curl: (56) Recv failure: Connection reset by peer` but so does localhost:8080 and 127.0.0.1:8080

I have tried this in httpd.conf same results

---

<div class="post-metadata">

### Author: ![Cameron\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cameron_d/32/97535_2.png) [@Cameron\_D](https://meta.discourse.org/u/Cameron_D)
#### Post date: [July 7, 2018, 1:45pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/26 "2018-07-07T13:45:35Z")

</div>

Is something blocking loopback connections then? Firewall?

---

<div class="post-metadata">

### Author: ![Cameron\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cameron_d/32/97535_2.png) [@Cameron\_D](https://meta.discourse.org/u/Cameron_D)
#### Post date: [July 7, 2018, 1:53pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/27 "2018-07-07T13:53:09Z")

</div>

💡 You’re running CentOS. Is SELinux enabled? That might be blocking Apache from opening connections.

Try `setsebool -P httpd_can_network_connect` to allow Apache to open connections.

Check here [https://serverfault.com/questions/563872/selinux-allow-httpd-to-connect-to-a-specific-port](https://serverfault.com/questions/563872/selinux-allow-httpd-to-connect-to-a-specific-port) for more details on allowing specific ports.

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 7, 2018, 1:59pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/28 "2018-07-07T13:59:37Z")

</div>

Thanks again for the input. iptables has no rule for 8080 port ACCEPT or REJECT, netstat tells that  
`tcp6 0 0 :::8080 :::* LISTEN 15160/docker-proxy`  
means docker proxy is 8080 and SELinux is disabled. I checked.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 7, 2018, 2:00pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/29 "2018-07-07T14:00:08Z")

</div>

> [@itsbhanusharma](#):
>
> How can it be that it works fine on other ports but not on port 80 though?

Hmm. Perhaps I misunderstood the OP.

> [@Aashish\_Gangwani](#):
>
> `curl http://0.0.0.0:8080/` gives `curl: (56) Recv failure: Connection reset by peer` but so does localhost:8080 and 127.0.0.1:8080

If `curl http://localhost:8080/` doesn’t give you Discourse, then I’d say something is wrong with Discourse. Do you have any plugins installed?

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 7, 2018, 2:06pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/30 "2018-07-07T14:06:10Z")

</div>

No I have no plugins installed. I checked all logs of discourse carefully there are no errors and it is working on port 8080.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 7, 2018, 2:07pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/31 "2018-07-07T14:07:17Z")

</div>

Does Discourse have `force_https` turned on and apache is trying to access http?

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 7, 2018, 2:08pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/32 "2018-07-07T14:08:18Z")

</div>

How do I check this? Is there any other config file for discourse?

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [July 7, 2018, 2:10pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/33 "2018-07-07T14:10:03Z")

</div>

If you can access forum on 8080 then log in as admin and check the admin setting called ` force https`

It _should_ be disabled to make it work on http

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 7, 2018, 2:20pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/34 "2018-07-07T14:20:01Z")

</div>

I just checked..Its disabled.

---

<div class="post-metadata">

### Author: ![Cameron\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cameron_d/32/97535_2.png) [@Cameron\_D](https://meta.discourse.org/u/Cameron_D)
#### Post date: [July 7, 2018, 10:15pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/35 "2018-07-07T22:15:26Z")

</div>

> [@pfaffman](#):
>
> If `curl http://localhost:8080/` doesn’t give you Discourse, then I’d say something is wrong with Discourse. Do you have any plugins installed?

But you can currently access the site via port 8080. An earlier post has this link: [http://forum.6figureswithchris.com:8080/](http://forum.6figureswithchris.com:8080/) so Discourse is working

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [July 7, 2018, 10:29pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/36 "2018-07-07T22:29:58Z")

</div>

Do you have X-Forwarded-For IP chaining set up properly? If that’s broken, the “flooding protection” in the discourse-internal-NGINX will stop dropping connections (because all traffic is coming from a single IP).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [July 8, 2018, 7:48pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/37 "2018-07-08T19:48:45Z")

</div>

A post was split to a new topic: [Multisite installation not available after rebuild](https://meta.discourse.org/t/multisite-installation-not-available-after-rebuild/91834)

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 8, 2018, 8:52am UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/38 "2018-07-08T08:52:13Z")

</div>

How do I check this, please? I checked some stackoverflow answers but couldnt understand how to check this…

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [July 8, 2018, 6:19pm UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/40 "2018-07-08T18:19:47Z")

</div>

Well, the mod\_proxy documentation doesn’t suggest you can turn it off, actually: [mod\_proxy - Apache HTTP Server Version 2.4](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#x-headers)

---

<div class="post-metadata">

### Author: ![Aashish\_Gangwani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aashish_gangwani/32/119765_2.png) [@Aashish\_Gangwani](https://meta.discourse.org/u/Aashish_Gangwani)
#### Post date: [July 9, 2018, 7:23am UTC](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660/41 "2018-07-09T07:23:12Z")

</div>

Yeah its on. I checked with `httpd -M` in CentOS system this command tells what all modules are active.

[Previous page](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660.md?page=1)

[Next page](https://meta.discourse.org/t/502-bad-gateway-apache-proxy-multi-site-config/91660.md?page=3)
