part 3 apache content negotiation and content restriction

content negotiation

responds to http/1.1 request header options
presents client with bestmatch resources http/1.1
-alternate language, character set ,media type etc
handled by - mod_negotiation

content negotiation is based on 2 methods-
1 type maps - *.var file -include variants
2 MultiViews - server auto searches for alternatives based on client request

task:
negotiate content based on language

vim  index.html.var

URI: index.html

URI: index.html
Content-type: text/html
Content-language: en

URI: index.html.es
Content-type: text/html
Content-language: es


content restriction

restricts access to content based on
1 <Directory>
2 <Location> -url webspace
3 <Files>
4 <Auth> authentication related directives

default config restricts access to .htaccess , .ht* files

Tasks:
1) <Directory> - applies to filesystem location
<Directory /home/site2/www/private>
  Order allow,deny
  Allow from 127.0.0.1 192.179.90.22
</Directory>

 effectively take content offline from webspace
 <Directory /home/site2/www/private>
     Order deny,allow
     Deny from all
 </Directory>

 Use <Location> applies restriction based on URL string

 <LocationMatch ^/priv> - traps variants including but not limited to "/private , /priv ,/privilege , /primary etc"
 <LocationMatch ^/priv>
     Order deny,allow
     Deny from all
 </LocationMatch>
   eg -  example.com/privtt is restricted OR
  
   <Location ~ ^/priv>
   Order deny,allow
   Deny from all
   </Location>

 <Files> to restrict based on files
 NOTE:- it should be placed under <Directory> block or in .htaccess in particular directory as needed
 <Files ~ "\.(xls|docx|sql|pdf)">
 Order deny,allow
 deny from all
 </Files>
 <FilesMatch "\.">
   Order deny,allow
   Deny from all
 </FilesMatch




No comments:

Post a Comment