[b]"How to properly configure an Apache reverse proxy for multiple domains?"[/b] or [b]"Apache reverse proxy setup

14 Replies, 1690 Views

"Apache reverse proxy setup – why is my backend server not being reached?"

Hey folks,

So I set up an apache reverse proxy for my two domains, but the backend server just ain't responding.

Config looks fine (I think?):
```
ProxyPass / http://backend:8080/
ProxyPassReverse / http://backend:8080/
```

But all I get is 504 timeouts.

- Backend works fine if I hit it directly.
- Firewall’s open, ports are forwarded.
- Even tried adding `Allow from all` just in case.

Am I missing something dumb? Maybe DNS? Or does the apache reverse proxy need extra modules enabled?

Thanks in advance!

(Also, if anyone’s got a solid guide for multi-domain setups, drop a link. My Google-fu’s failing me today.)
Hey! Had the same issue last week. Turns out my backend server wasn’t resolving the hostname "backend" from the apache reverse proxy. Try replacing `backend` with the actual IP in your ProxyPass directives.

Also, check if mod_proxy and mod_proxy_http are enabled:
```
a2enmod proxy
a2enmod proxy_http
```

For multi-domain setups, DigitalOcean’s guide is solid. Helped me big time.
504s usually mean the proxy can’t reach the backend. Double-check:

- Is `backend:8080` accessible from the apache server itself? Try `curl http://backend:8080` on the proxy box.
- Maybe SELinux or AppArmor blocking the connection? Temporarily disable to test.

Btw, for debugging, enable apache reverse proxy logs:
```
LogLevel debug
```
Yo, DNS could totally be the culprit. If you’re using container names (like Docker) or local hostnames, the apache reverse proxy might not resolve them.

Try pinging `backend` from the proxy server. If it fails, either use IPs or tweak your `/etc/hosts`.

Also, this tool’s handy for testing proxy configs: https://httpd.apache.org/docs/trunk/mod/mod_proxy.html
Sounds like a networking issue. Even if the firewall’s open, the backend might not accept requests from the proxy’s IP.

Check the backend’s logs—see if it’s even getting hit. If not, the apache reverse proxy isn’t forwarding properly.

Side note: For multi-domain, you’ll need NameVirtualHost or separate VirtualHost blocks.
504 timeout screams "connection refused." Are you sure the backend listens on 0.0.0.0:8080 and not just localhost?

Run `netstat -tulnp` on the backend to confirm.

Also, apache reverse proxy sometimes needs `ProxyPreserveHost On` to pass the right headers.
Had this exact headache. For me, it was the backend server’s reverse proxy settings—it was only allowing requests from specific IPs.

Add this to your backend config if it’s Nginx or similar:
```
set_real_ip_from <proxy-ip>;
```

For apache reverse proxy, maybe try `ProxyRequests Off` to avoid misconfigs.
UPDATE: Yo, thanks for all the tips! Replaced `backend` with the IP and boom—it works. Turns out my Docker network was being weird with hostnames.

Still gotta figure out the multi-domain part, but at least the apache reverse proxy is talking to the backend now.

Anyone got a slick way to handle multiple domains without duplicating the ProxyPass lines? VirtualHosts seem messy...



Users browsing this thread: 1 Guest(s)