The first step
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
Step Two
In Ubuntu Apache, each site's configuration file is placed in a separate file, find the corresponding files in the Sites-available folder and modify, the modified configuration file is almost the following look.
ServerName www.a.com
DocumentRoot "/var/site/www/"
Proxyrequests OFF
<proxy *>
Order Deny,allow
Allow from all
</Proxy>
proxypass/http://host.com/
proxypassreverse/http://host.com/
Proxyrequests is the type of proxy, if it is on it represents the forward proxy, we need to reverse proxy, set to OFF. proxypassreverse/http://host.com/It means that all requests from the root directory are proxied to the root directory of the http://host.com/.
Step Three
Restart Apache Service
Service Apache Restart
Here, say something.an overview of Proxypass and Proxypassreverse and Proxypassmatch
1, Proxypass:
Syntax: proxypass [path]!| Url
It is mainly used as a URL prefix match, cannot have a regular expression , it is configured within the path is actually a virtual path, after the reverse proxy to the back-end URL,path is not brought past , using the example:
1), proxypass/images/!
This example indicates that the/images/request is not forwarded.
2), proxypass/mirror/foo/http://backend.example.com/
We assume that the current service address is http://example.com/, if we make the following request:
Http://example.com/mirror/foo/bar
That will be turned into an internal request:
Http://backend.example.com/bar
Note: When configured, you do not need a forwarded request to be configured in front of the request that needs to be forwarded.
2, Proxypassmatch:
syntax: proxypassmatch [regex]!| URL
This is actually a URL regular match , rather than a simple prefix match, the regex portion of the match is taken to the backend URL, which is different from Proxypass. Examples of Use:
1, Proxypassmatch ^/images!
This example indicates that a request to/images will not be forwarded.
2, Proxypassmatch ^ (/.*\.gif) $ http://backend.example.com$1
This example indicates that requests for all GIF images are forwarded to the backend, such as request http://example.com/foo/bar.gif at this time, and the internal will be converted to such request http://backend.example.com/foo/bar.gif.
3, Proxypassreverse
Syntax: proxypassreverse [path] url
It is generally used in conjunction with the PROXYPASS directive, which enables Apache to adjust the URL of the location, content-location, and URI header in the HTTP redirect response, which avoids the use of Apache as a reverse proxy. HTTP redirection of the backend server caused the problem of bypassing the reverse proxy. See the following example:
Proxypass/example http://www.example.com/
Proxypassreverse/example http://www.example.com/
Proxypassreverse's role is to reverse proxy, if not add such a reverse proxy setting, access to http://www.test.com/example/a, If www.example.com redirect the request to http://www.example.com/b, the client bypasses the reverse proxy and accesses the http://www.test.com/example/b. If a reverse proxy is set, it will be adjusted to http://www.test.com/example/a/b before forwarding the HTTP redirect to the client, that is, appending the redirect path after the original request.
Ubuntu 14.04+apache Reverse proxy settings