What is ProxyPreserveHost in Apache?
I am new to Apache web server, and have been stuck at the ProxyPreserveHost directive in conf.
file. Can anyone tell me what is the use of this ProxyPreserveHost and how it works?
In short, this tells the proxy to pass requests from a domain with a specified subdomain intact (ie. Example.com), but change the Host: header to yourdomain.com)
A lot of web server software these days is based on Apache HTTP Server 2.4 and older, so some of the older documents won't quite cut it, but this should answer your question.
For the full details, you'll need to refer to RFC 2616 and the relevant section of the documentation.
Can you use Apache as a reverse proxy?
I understand that Apache can be configured to act as a reverse proxy.
It means we can make our application accessible over the internet using a url like and it will be internally routed by Apache to the myapp running on the box. Is this configuration possible? You can use a web server like Apache for this, but this is a little bit different than a reverse proxy, since you want your web server to handle the connections, not another web server like Lighttpd or nginx (with reverse proxy). Apache offers this in its HTTP daemon, but you can also configure it as a reverse proxy.
What is the Host header in reverse proxy?
The Host header in a reverse proxy is used to indicate the protocol of the client behind the reverse proxy.
It's also known as proxy-forwarded-for header or proxy-for-web. It has a great use in a scenario where the client is behind a load balancer and the load balancer is using reverse proxy to forward all requests to the web server. The idea is simple: the load balancer will strip off the original host headers and it will add the public IP of the load balancer in the request's Host header. So, when the reverse proxy receives the request, it sees the request's original Host header and then based on its configuration, forwards the request to one or more of the backend web servers. In short, the Host header in reverse proxy provides a great deal of functionality and its use is very common.
When you talk about the Host header, most of the time you would want to check whether the client's host header matches the Host header of the request. But, it is very important to remember that the reverse proxy may also modify the request's headers based on some configuration options. Therefore, the host headers of the request that you receive might differ from what is actually set in the request headers. For example, you may see that a request from the clients comes with a Host header value that is different from what you configured on the reverse proxy side. You would need to do additional research in order to identify the root cause of this difference. However, this doesn't mean you cannot get the correct host header values by parsing the request's Host header. In this post, I will show you how to identify the host header values based on the request's Host header.
Example of a reverse proxy which uses the Host header to configure the access patterns. Let us take a look at an example to understand how the Host header works in reverse proxy and how you can identify the host headers values based on the request's Host header. Suppose, you have an application running behind a reverse proxy and let us assume that it is configured to accept requests from HTTP clients with IP address starting with 10.0/16. So, whenever the client with an IP address that starts with 10.0/16 sends a request, the reverse proxy will pass it to your application.
What is proxy keep alive in Apache?
There's no direct answer, but there are a number of possible solutions, all of which are fairly advanced topics in Apache configuration.
Here's a quick overview of the two most common: Apache KeepAlive. This is an Apache extension that is designed to automatically restart a worker process when it dies. It works by writing a file to the server's logs, and notifying the Apache server of the failure. Apache will then restart the worker, and the newly restarted process will pick up where the old one left off. This is the "best" solution, and is used heavily in commercial applications.
Pros: Works in most situations. Integrated with Apache as a module, so any other modules will automatically restart workers as well. Is very powerful and flexible. Cons: Not easy to configure. Requires kernel patches for Linux and Windows. PHP's apcserverstart(). PHP has a native mechanism for doing this, which uses a shared memory cache. This is more difficult to configure than KeepAlive, but is much easier to configure than writing to the logs. It also allows you to change the cache size, so you can have the "fast" cache for small requests, and a larger cache for larger requests.
Easier to configure. No kernel changes needed. Not as fast as KeepAlive. In either case, if you want to do this for a single request, the best solution is to run a thread pool (ie PHP's apcfetch()).
Related Answers
What are the two types of proxies?
You can use a reverse proxy for multiple reasons, but mostly it is us...
Why is it called a reverse proxy?
What is the difference between a reverse proxy an...
Does Apache support reverse proxy?
I have a.war application which is deployed in the Tomcat server. br...