You can configure conditional request processing in reverse proxy by manually editing the virtual server specific obj.conf file or through CLI. After the configuration changes are done, it is recommended to deploy the configuration and start the instance so that the changes are implemented.
wadm>deploy-config config_name |
wadm>start-instance --config config_name hostname |
See CLI Reference, deploy-config(1), start-instance(1)
The appropriate obj.conf file used by your virtual server should be modified. It can be <vs>-obj.conf or the default obj.conf, depending on the configuration.
The following examples discuss some of the possible configurations in Web Server.
Configuring reverse proxy for all .jsp, .php requests.
Create a rp configuration.
wadm>create-config --http-port=8081 --server-name=rp --server-user=root rp
Enable the rp configuration to reverse proxy using the following command:
wadm> create-reverse-proxy --user=admin --password-file=admin.pwd --host=serverhost --config=rp --vs=rp --uri-prefix=// --server=http://rick.india.sun.com:8080 |
Disable Java for the rp configuration.
wadm disable-java --user=admin --password-file=admin.pwd --host=serverhost --config=rp |
See CLI Reference, disable-java(1).
Create an instance for the rp configuration.
wadm>create-instance --config=rp <host-name>
Modify the <vs>-obj.conf
file,
so that the above expression is added to the NameTrans fn="map" directive.
NameTrans fn="map" from="/" to="http:/" name="custom_reverse_proxy" ... <Object name ="custom_reverse_proxy"> Route fn="set-origin-server" server="http://<hostname>:<port>" </Object> <Object name ppath="http:*" Service fn="proxy-retrieve" method="*" </Object> |
Configuring http-referer header in reverse proxy.
Create a rp configuration.
wadm>create-config --http-port=8081 --server-name=rp --server-user=root rp
Enable the rp configuration to reverse proxy using the following command:
wadm> create-reverse-proxy --user=admin --password-file=admin.pwd --host=serverhost --config=rp --vs=rp --uri-prefix=/ilearn --server=http://rick.india.sun.com:8080 |
Create an instance for the rp configuration.
wadm>create-instance --config=rp <host-name>
Modify the <vs>-obj.conf
file,
so that the above expression is added to the NameTrans fn="map" directive.
<Object name="reverse-proxy-/ilearn"> NameTrans fn="set-variable" $headers{'Referer'}="http://learning.sun.com/TOI/LEARN.html" Route fn="set-origin-server" server="http://spb-sls-dev.russia.sun.com:7777" </Object> |
Setting up a simple failover scenario for the reverse proxy functionality.
For example, in a setup there are two reverse proxies which proxy to two separate web servers without load balancing. There is a one to one relationship in a normal scenario. However, if one backend server is down the reverse proxy should send request to the other live web server. Modify the obj.conf file as shown below.
<Object name="default"> <If $path =~ '/servlet' or $path =~ '\.jsp'> <If not $restarted> NameTrans fn="map" name="reverse-proxy" from="/" to="http:" </If> <If $restarted> NameTrans fn="map" name="reverse-proxy-alt" from="/" to="http:" </If> </If> </Object> <Object name="reverse-proxy"> Route fn="set-origin-server" server="<back-end-server>" # If back end server is not available, restart the request <If $code =~ 504> Error fn="restart" uri="$uri" </If> </Object> <Object name="reverse-proxy-alt"> Route fn="set-origin-server" server="<alternate-back-end-server>" </Object> <Object ppath="http:*"> Service fn="proxy-retrieve" method="*" </Object> |
For every request, the server will first try to reach the first backend server. When this is not available, the request will be sent to the failover server or alternate backend server.
Setting up a software load balancer to two web server instances that host dynamic content.
Add server names in the server parameter, separated by a comma (,) and execute the command through CLI.
wadm> create-reverse-proxy --user=admin --password-file=admin.pwd --host=serverhost --config=rp --vs=rp --uri-prefix=// --servers=hostname:port,hostname1:port |
Configuring timeout value for reverse proxy.
The Web Server 7.0 configured with reverse proxy, returns a gateway timeout error as the backend server takes a long time to respond. You can set the timeout value through CLI as below:
wadm> set-reverse-proxy-prop --user=admin --password-file=admin.pwd --host=serverhost --config=rp --vs=rp--uri-prefix=// --server=http://rick.india.sun.com:8080 timeout=400 |
See CLI reference, set-reverse-proxy-prop(1).
The default timeout value is 300 seconds. Once the response timeout value is defined, if the connection hangs for more than 400 seconds, the reverse proxy identifies the backend instance offline and closes the connection.