I am unable to correctly configure a reverse proxy for a web server. I have looked here and in other places for solutions to similar problems, but none seem to have helped in my case. Here is the setup:

I have an apache proxy server handling requests for virtual web servers in my environment (all on ubuntu 16.04.1). DNS is being handled externally (Cloudflare) and point to my one public IP address. My goal is to have the proxy server pass the requests to the correct virtual web server.

I have an internal DNS server and have confirmed that the virtual web servers are operating normally (all are accessible to internal requests), but when attempting to access externally, I'm unable to resolve any of them.

The following is my configuration for the proxy server virtual host:

ServerName foo.com
ProxyRequests off
ProxyPass / http://foo.com/
ProxyPassReverse  / http://foo.com/

This seems to result in a timeout. This is the error I'm receiving in the apache logs on the proxy server:

[proxy_http:error] [pid 28581] (70007)The timeout specified has expired: [client] AH01102: error reading status line from remote server foo.com:80, referer: http://foo.com
[proxy:error] [pid 28581] [client] AH00898: Error reading from remote server returned by /, referer: http://foo.com

As suggested in other similar questions, I've added the following lines to my apache config on the proxy server:

SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
SetEnv proxy-initial-not-pooled 1

However, now external requests are throwing a 502 after about 60 seconds, specifically stating:

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /.

Reason: Error reading from remote server

I have also tried this for my virtual host on the proxy server:

ServerName foo.com
ProxyRequests off
ProxyPass /
ProxyPassReverse  /

Which results in a redirect loop.

I'd be happy to provide more details about my configuration.

  • first connect to the same machine your reverse proxy is in and try to connect to your backend the same way, example: curl http://foo.com/ and curl – ezra-s Feb 6 '17 at 11:39
  • @ezra-s Thanks - so I reconfigured the proxy server from scratch and everything seems to be working OK now. I did use the curl tests (which is another tool for the troubleshooting toolbox, so thanks!) and was able to successfully reach the webserver. I was able to do an external test as well and everything worked. I believe I had some incorrect SSL settings that I did not convert/transfer over correctly to allow the proxy server to process those requests correctly (hence the looping). Though, I'm not sure exactly what the specific issue was. Thank you for your help!, – kbeaulieu Feb 6 '17 at 21:43

I scrapped my initial configuration, which I believed had some lingering SSL configurations that were not appropriate/compatible with the proxy server and thus resulting in a redirect loop. Redoing the entire proxy server and retesting got the expected results (external access to the webserver through the proxy).

  • In my case, the proxied server serves http. The configured ProxyPass / ProxyPassReverse directives had "https://" on the URL. Lingering SSL configuration - thanks. – EpicVoyage Oct 22 '18 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.