Problem
Using a reverse-proxy Apache setup and location directives, it's fairly straightforward to deny access to URL locations. For example, if you want to deny access to https://confluence.jaytaala.com/aboutconfluencepage.action you could simply add the following in the confluence subdomain vhost:
<Location /aboutconfluencepage.action> Require all denied </Location>
For this location you might also want to add a custom ErrorDocument 403 message specific to this location. ErrorDocument cannot be used within a Location directive (can be used in Directory, vhost, etc. though). Below is an approach I use sometimes to use a custom ErrorDocument for a URL location, and/or to use ProxyPassMatch and regex expressions to match and block URL location patterns.
Solution
The basic approach here is to define a vhost on a spare port which blocks all access and displays a custom ErrorDocument message. We'll use RewriteRule with the [P] flag to proxy it to port 403.
Below is an example of an apache proxy conf file (taken from this page):
# Listen to port 403 for showing access denied Listen 403 # vhost for denying access and showing ErrorDocument <VirtualHost *:403> <Location /> Require all denied </Location> ErrorDocument 403 "<h3>Access denied</h3>" </VirtualHost> <VirtualHost *:443> ServerName confluence.jaytaala.com ProxyRequests Off ProxyVia Off ProxyPreserveHost On # Block pages/actions RewriteEngine On RewriteCond %{REQUEST_URI} aboutconfluencepage.action$ [OR] RewriteCond %{REQUEST_URI} configurerssfeed.action$ [OR] RewriteCond %{REQUEST_URI} createrssfeed.action$ RewriteRule ^/(.*) http://127.0.0.1:403/$1 [P] #<OTHER STUFF GOES HERE> </VirtualHost>
You'll note that we listen to port 403 and define a vhost for said port. This vhost simply denies all access and has an associated ErrorDocument 403 message that will be displayed.
Also note the RewriteCond arguments and will send all requests to aboutconfluencepage.action and configurerssfeed.action to my port 403 vhost. I use RewriteCond and a regex expression so that https://confluence.jaytaala.com/aboutconfluencepage.action and https://confluence.jaytaala.com/dashboard/aboutconfluencepage.action are both blocked.
The [OR] flag is simply that... OR (as opposed to the default/implicit AND that is used for multiple RewriteCond lines).
Simple and straight-forward...
References
Related articles