Skip to content
A squid redirector
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore first commit. Jul 23, 2016 update readme Jul 25, 2016
main.go add redirect(302,301) support Jul 25, 2016
squid-urlrewrite.conf add redirect(302,301) support Jul 25, 2016

Squid Url Rewriter

This program is for url_rewrite_program, and concurrency support.

Require: squid-3.4+


go get

squid config:

url_rewrite_program /path/to/squid-urlrewrite
url_rewrite_children 20 startup=1 idle=1 concurrency=10000

rewrite config file location:

search in this order:

squid-urlrewrite.conf example:

# example

# loglevel
# info: default
# debug: more detail info
# log messages are write to syslog
loglevel debug

# rewrite  <regexp> <target>
# redirect <regexp> [301;]<target>

rewrite  ^https?://webserver\.domain\.com/file/(\d+)/$1

redirect ^(https?://)domain\.com/(.*)$		    301;$$2

redirect ^(https?://)www\.domain2\.com/(.*)$	    $$2   

reload configure

kill -HUP <pid of squid-urlrewrite>


squid -k reconfigure


$ ./squid-urlrewrite
1  // <-- input
1 OK rewrite-url="" // <-- response
2 ERR // <-- It's ok, means no rewrite rule matched.
3 OK status=301 url="" <-- 301 redirect

About squid redirector

You can’t perform that action at this time.