README
changeset 27 bf206815c2ab
parent 26 7b28fb383da2
child 30 5cc836e06759
equal deleted inserted replaced
26:7b28fb383da2 27:bf206815c2ab
    34 Configuring squid
    34 Configuring squid
    35 -----------------
    35 -----------------
    36 
    36 
    37 You must enable url rewriting from within the squid.conf file.
    37 You must enable url rewriting from within the squid.conf file.
    38 
    38 
    39 	url_rewrite_program /usr/local/bin/volta
    39     url_rewrite_program /usr/local/bin/volta
    40 
    40 
    41 ... and that's it.  You may need some additional customization, like where
    41 ... and that's it.  You may need some additional customization, like where
    42 the volta database is stored on disk:
    42 the volta database is stored on disk:
    43 
    43 
    44 	url_rewrite_program /usr/local/bin/volta -f /var/db/squid/volta.db
    44     url_rewrite_program /usr/local/bin/volta -f /var/db/squid/volta.db
    45 
    45 
    46 Busy servers:
    46 Busy servers:
    47 
    47 
    48 Make sure rewrite_concurrency is disabled, volta is single threaded.
    48 Make sure rewrite_concurrency is disabled, volta is single threaded.
    49 Instead, just add more volta children.  They are lightweight, so load em
    49 Instead, just add more volta children.  They are lightweight, so load em
    50 up.  A proxy at my $DAYJOB is in use by around 450 people, and we get by
    50 up.  A proxy at my $DAYJOB is in use by around 450 people, and we get by
    51 nicely with 10 volta children.
    51 nicely with 10 volta children.
    52 
    52 
    53 	url_rewrite_concurrency 0
    53     url_rewrite_concurrency 0
    54 	url_rewrite_children 10
    54     url_rewrite_children 10
    55 
    55 
    56 
    56 
    57 Using volta
    57 Using volta
    58 -----------
    58 -----------
    59 
    59 
    60 See the INSTALL file for instructions on how to compile volta.
    60 See the INSTALL file for instructions on how to compile volta.
    61 
    61 
    62 Volta reads its rewrite rules from a local database.  You can create the
    62 Volta reads its rewrite rules from a local database.  You can create the
    63 rules in a text editor, then convert it to the database like so:
    63 rules in a text editor, then convert it to the database like so:
    64 
    64 
    65 	% volta -c rules.txt
    65     % volta -c rules.txt
    66 
    66 
    67 You'll be left with a "volta.db" file in the current directory.  Put it
    67 You'll be left with a "volta.db" file in the current directory.  Put it
    68 wherever you please, and use the -f flag to point to it.
    68 wherever you please, and use the -f flag to point to it.
    69 
    69 
    70 
    70 
   100       rules per hostname.  Hostnames are compared without case sensitivity.
   100       rules per hostname.  Hostnames are compared without case sensitivity.
   101 
   101 
   102 
   102 
   103     Second field: the path to match.
   103     Second field: the path to match.
   104 
   104 
   105 	  This can be an exact match ('/path/to/something.html'), a regular
   105       This can be an exact match ('/path/to/something.html'), a regular
   106 	  expression ('\.(jpg|gif|png)$'), or a single '*' to match for any
   106       expression ('\.(jpg|gif|png)$'), or a single '*' to match for any
   107 	  path. Regular expressions are matches without case sensitivity.  There
   107       path. Regular expressions are matches without case sensitivity. There
   108 	  is currently no support for capturing, though this may be added in
   108       is currently no support for capturing, though this may be added in a
   109 	  a future release.
   109       future release.
   110 
   110 
   111 
   111 
   112     Third field: The redirect code and url to rewrite to.
   112     Third field: The redirect code and url to rewrite to.
   113 
   113 
   114       Any pieces of a url that are omitted are automatically replaced with
   114       Any pieces of a url that are omitted are automatically replaced with
   121 
   121 
   122 ### Negative matches:
   122 ### Negative matches:
   123 
   123 
   124     First field: the hostname to match.
   124     First field: the hostname to match.
   125 
   125 
   126 	  See above -- all the same rules apply.
   126       See above -- all the same rules apply.
   127 
   127 
   128 
   128 
   129     Second field: the path to match.
   129     Second field: the path to match.
   130 
   130 
   131 	  See above -- all the same rules apply.
   131       See above -- all the same rules apply.
   132 
   132 
   133 
   133 
   134 	Third field: the 'negative' marker.
   134     Third field: the 'negative' marker.
   135 
   135 
   136 	  This is simply the '-' character, that signals to volta that this is
   136       This is simply the '-' character, that signals to volta that this is
   137 	  a negative matching rule.
   137       a negative matching rule.
   138 
   138 
   139 
   139 
   140 You can easily test your rules by running volta on the command line, and
   140 You can easily test your rules by running volta on the command line, and
   141 pasting URLs into it.   Boost the debug level (-d4) if you're having any issues.
   141 pasting URLs into it.   Boost the debug level (-d4) if you're having any issues.
   142 
   142 
   146 
   146 
   147 Rewrite all requests to Google to the SSL version:
   147 Rewrite all requests to Google to the SSL version:
   148 
   148 
   149     google.com * 302:https://www.google.com
   149     google.com * 302:https://www.google.com
   150 
   150 
   151 	This will redirect the request "http://www.google.com/search?q=test" to
   151     This will redirect the request "http://www.google.com/search?q=test" to
   152 	"https://www.google.com/search?q=test".
   152     "https://www.google.com/search?q=test".
   153 
   153 
   154 
   154 
   155 Transparently alter all uploaded images on imgur to be my face:  :)
   155 Transparently alter all uploaded images on imgur to be my face:  :)
   156 
   156 
   157 	i.imgur.com \.(gif|png|jpg)$ http://www.martini.nu/images/mahlon.jpg
   157     i.imgur.com \.(gif|png|jpg)$ http://www.martini.nu/images/mahlon.jpg
   158 
   158 
   159 
   159 
   160 Expand a local, non qualified hostname to a FQDN (useful alongside the
   160 Expand a local, non qualified hostname to a FQDN (useful alongside the
   161 'dns_defnames' squid setting to enforce browser proxy behaviors):
   161 'dns_defnames' squid setting to enforce browser proxy behaviors):
   162 
   162 
   163 	local-example * local-example.company.com
   163     local-example * local-example.company.com
   164 
   164 
   165 
   165 
   166 Cause all blog content except for 2011 posts to permanently redirect to
   166 Cause all blog content except for 2011 posts to permanently redirect to
   167 an archival page:
   167 an archival page:
   168 
   168 
   169 	martini.nu /blog/2011 -
   169     martini.nu /blog/2011 -
   170 	martini.nu /blog 301:martini.nu/content-archived.html
   170     martini.nu /blog 301:martini.nu/content-archived.html
   171 
   171