Apache deny calls to a specific URI based on user agent

<LocationMatch “.*/messages.json.*”>
SetEnvIfNoCase User-Agent “AdobeAIR” desktop
Order allow,deny
Allow from all
Deny from env=desktop
</LocationMatch>

<Directory> does not work when apache does just proxypass.

 

Here is the complete sample.

 

<VirtualHost *:80>
ErrorDocument 503 /errors/503/index.html
CustomLog ${APACHE_LOG_DIR}/access_log combined

<Proxy balancer://website>
BalancerMember http://127.0.0.1:3000
</Proxy>
<Proxy balancer://api_server>
BalancerMember http://127.0.0.1:3001
</Proxy>
<Proxy balancer://images_server>
BalancerMember http://127.0.0.1:3002
</Proxy>
ProxyPass /server-status !
ProxyPass /errors !
ProxyPass /a balancer://api_server/
ProxyPass /images balancer://images_server/
ProxyPass / balancer://website/

# Compress text and image types
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript image/jpeg image/png image/gif text/css

<LocationMatch “.*/messages.json.*”>
SetEnvIfNoCase User-Agent “AdobeAIR” desktop
Order allow,deny
Allow from all
Deny from env=desktop
</LocationMatch>

<LocationMatch “.*/(images|javascripts|stylesheets)/.*$”>
Header unset ETag
FileETag None
ExpiresActive On
ExpiresDefault “access plus 1 year”
</LocationMatch>

</VirtualHost>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s