GithubHelp home page GithubHelp logo

squid-urlrewrite's Introduction

Squid Url Rewriter

This program is for url_rewrite_program, and concurrency support.

Require: squid-3.4+

Install

go get github.com/rchunping/squid-urlrewrite

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:
/<program_dir>/squid-urlrewrite.conf
/usr/local/etc/squid-urlrewrite.conf
/etc/squid-urlrewrite.conf

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+)/  http://192.168.1.3:1234/backend/file/read?file_id=$1

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

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

reload configure

kill -HUP <pid of squid-urlrewrite>

or

squid -k reconfigure

Test

$ ./squid-urlrewrite
1 http://webserver.domain.com/file/123/test.png  // <-- input
1 OK rewrite-url="http://192.168.1.3:1234/backend/file/read?file_id=123" // <-- response
2 http://github.com
2 ERR // <-- It's ok, means no rewrite rule matched.
3 http://domain.com/index.html
3 OK status=301 url="http://www.domain.com/index.html" <-- 301 redirect

About squid redirector

http://wiki.squid-cache.org/Features/Redirectors

squid-urlrewrite's People

Contributors

rchunping avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

squid-urlrewrite's Issues

Installing...

Hello,

I'm trying to use this with Squid4 and it just doesn't seem to be working. I realize you probably don't update this anymore but is there any clarity to how to install it?

I'm wondering if I'm just installing it incorrectly?

The files I have are main.go and the .conf.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.