Created
March 22, 2017 19:56
-
-
Save freyes/b72a39b71b6d92239550895d78cd7e30 to your computer and use it in GitHub Desktop.
Redirect ubuntu archive requests to another mirror when using squid as an apt proxy (or transparent proxy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| # | |
| # url_rewrite_program /etc/squid/rewrite.pl | |
| # add ^^^ to your squid.conf | |
| # | |
| $mirror = "example.com"; | |
| $| = 1; | |
| while (<>) { | |
| @line = split; | |
| $_ = $line[0]; | |
| if (m/^http:\/\/((?:[a-z0-9]+\.)?archive\.ubuntu\.com)\/(.*)/ && | |
| $1 ne $mirror) { | |
| print "http://" . $mirror . "/" . $2 . "\n"; | |
| } else { | |
| print $_ . "\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment