There exists a web application (JQuery and Spring) running on weblogic application server. There's a apache http server while watching application server. All incoming demands can come with the web server and reaches the application server.

We now have essential that we must verify for any value within the incoming http request header and when present, the request needs to delivered to the application server. Otherwise we've block the request and as a result display a static error page towards the consumer.

I wish to know whether we are able to implement this logic within the apache http server. Please advice.

This can be done with mod_rewrite. You did not include what your exact system is, but when you've got a mod_proxy type config you want to make certain the rewrites don't hinder the passage of normal traffic. Inside a general sense, inside your Apache config, you'd:

  • Switch on rewrite
  • Look for the problem
  • Apply the rewrite rule in line with the conditions

To provide a very simple example, should you be searching for a type in the query string, and forbidding access (403) if it wasn't present, you'd make a move such as this:

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !somekey
RewriteRule ^.*$ - [F,L]

This is often as complicated as you want really, you are able to chain conditions together (implicit As well as an explicit or witht he [OR] flag) and you will serve a real page as opposed to a forbidden message.

Of course, support your config before tinkering, and it may be smart to test this by helping cover their .htaccess (though for performance reasons it's easier to move it towards the actual config for production loads).

The rewrite documentation is a superb resource too:

It truly is quite good documentation. For many pointers - you will need to lookup the flags ([L] = last [P] = treat like a proxied request [F] = forbidden etc.) and you'll need someone generally acquainted with regular expression syntax