Hitachi

uCosminexus Application Server HTTP Server User Guide


4.7.3 Example of system building

This subsection shows examples of configuring a system by using HTTP Server on the reverse proxy and the backend server.

You must be aware of the redirect process and specify the appropriate settings when configuring the system. If the client accesses the URL of a directory on the backend server without adding a forward slash (/) at the end of the URL, the backend server sends a redirect request with the Location header. In this case, the Location header value must be changed from the backend server address to the reverse proxy address to ensure that all client re-requests go through the reverse proxy.

The system network configuration is shown in the following figure. Also, each address is as follows:

Reverse proxy: www.example.com

Backend server: backend.example.com
Figure 4‒11: Network configuration

[Figure]

Organization of this subsection

(1) Recommended configuration

The host name and path name specified in the ProxyPass directive is the same as the host name and path name specified in the ProxyPassReverse directive. The ServerName directive is specified in all of the virtual hosts on the backend server, and the specification value is the same as the host name specified in the ProxyPassReverse directive on the reverse proxy.

The redirect process flow is shown in Table 4-6 when the reverse proxy and the backend server are configured as shown in Table 4-7 under the network configuration as illustrated in Figure 4-10.

Table 4‒6: Example to set the recommended configuration

Setting location

Setting contents

Reverse proxy

ServerName www.example.com

ProxyPass /before/ http://backend.example.com/after/

ProxyPassReverse /before/ http://backend.example.com/after/

Backend server

ServerName backend.example.com

Table 4‒7: Redirect process flow of recommended configuration

Location in the figure

Explanation

1

Access "http://www.example.com/before/dir".

2

Access "http://backend.example.com/after/dir" as per the ProxyPass directive value. Change and forward the Host header value in the backend.example.com.

3

Generate a URL that ends with a forward slash (/) because a forward slash (/) was not added to the end of the URL, set the URL in the Location header, and then return the redirect request.

4

Change and forward the Location header in the "http://www.example.com/before/dir/" as per the ProxyPassReverse directive value.

5

Access the "http://www.example.com/before/dir/" again as per the Location header.

A

Host header value is "www.example.com".

B

Host header value is "backend.example.com".

C

Location header value is "http://backend.example.com/after/dir/".

D

Location header value is "http://www.example.com/before/dir/".

#

When the backend server responds with a status code such as 302 Found or 404 Not found, the reverse proxy forwards the HTML document to the client without any changes. The backend server name mentioned in the HTML documents, such as 404 Not found and the redirect destination link address mentioned in 302 Found, are not changed to the reverse proxy information. Use the ErrorDocument directive on the backend server, or use the ProxyErrorOverride directive on the reverse proxy to prevent the client from seeing the backend server information.

(2) Configuration with the ProxyPreserveHost directive set to "On" in the reverse proxy

Normally, the reverse proxy converts the Host header value received from the client according to the ProxyPass directive value, and then forwards the converted value to the backend server. If you want to obtain the Host header value sent by the client as the Host header value in the backend server, set the value of the ProxyPreserveHost directive to On in the reverse proxy. Note the following points:

Table 4-8 shows the redirect process flow performed when the reverse proxy and the backend server are set as shown in Table 4-9 under the network configuration shown in the figure 4-10.

Table 4‒8: Example configuration where the ProxyPreserveHost is set to On in the reverse proxy

Setting location

Setting contents

Reverse proxy

ServerName www.example.com

ProxyPass /before/ http://backend.example.com/after/

ProxyPassReverse /before/ http://www.example.com/after/

ProxyPreserveHost On

Backend server

ServerName www.example.com

Table 4‒9: Redirect process flow of configuration where the ProxyPreserveHost is set to On in the reverse proxy

Location in the figure

Explanation

1

Access "http://www.example.com/before/dir".

2

Access "http://backend.example.com/after/dir" as per the ProxyPass directive. As the ProxyPreserveHost directive is set to On, the Host header value will remain as www.example.com.

3

Generate a URL that ends with a forward slash (/), because a forward slash (/) was not added to the end of the URL, set the URL in the Location header, and then return the redirect request.

4

Change and forward the Location header in "http://www.example.com/before/dir/" as per the value of ProxyPassReverse directive.

5

Access the "http://www.example.com/before/dir/" again, as per the Location header.

A

The value of Host header is "www.example.com".

B

The value of Host header is "www.example.com".

C

The value of Location header is "http://www.example.com/after/dir/".

D

The value of Location header is "http://www.example.com/before/dir/".