0

I have a domain int.business.com. When I hit this I want the browser to show the contents in the domain www.data.business.com but the users should still see int.business.com in the address bar. Here is my vhost configuration

RewriteEngine on
SSLProxyEngine on 
RewriteRule ^/(.*)$ int.business.com [P]
ProxyPassReverse / data.newbusiness.com

With this configuration, I am getting a 502 proxy error

Proxy Error
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

Any suggestions on how to solve this.

pradeep
  • 21
  • 1
  • 3

1 Answers1

0

You should modify your configuration like this:

ProxyPass        "/" "http://www.data.business.com"
ProxyPassReverse "/" "http://www.data.business.com"

The first argument is what you want to proxy, the second is the target of that proxy.

The SSLProxyEngine is not required, since you do not proxy to SSL anyway.

Doing a proxy with RewriteRule works, but performance is better with ProxyPass (due to persistent connections). See: https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_p for more details.

Also, you do not use any complicated regex here, so this is sufficient.

Make sure you load modules mod_proxy, mod_proxy_http.

Nic3500
  • 8,144
  • 10
  • 29
  • 40
  • I tried the above configuration. My actual domain is very long. So when I made the changes and trying to restart apache, the name is too long and it is trying to truncate it. I am not sure why. – pradeep Sep 19 '18 at 20:24
  • See this for the limits on domain names lengths: https://stackoverflow.com/questions/14402407/maximum-length-of-a-domain-name-without-the-http-www-com-parts – Nic3500 Sep 19 '18 at 21:08
  • Or this: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestline and http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize, which are configurable (no need to recompile your Apache). – Nic3500 Sep 19 '18 at 21:10