Coder Social home page Coder Social logo

squid-redirect's Introduction

squid-redirect

A json configurable squid(3.5) url_rewrite_program written in python3.

Usecase: We wanted to transparently point our ios simulators at different content servers without modifying the ios application under test. Each test run on our ci-servers can transparently alias different endpoints.

Examples

1.) Trial the url_rewrite_program flow in a terminal

    python3 squid-redirect.py --rewrite '{"www\.capitalfm\.com": "www.capitalfm.development.int.thisisglobal.com"}'
    0 http://www.capitalfm.com/_build/ -
    0 OK rewrite-url="http://www.capitalfm.development.int.thisisglobal.com/_build/"

2.) Startup an example squid server using our url_rewrite_program

    cat <<EOF > rules.json
    {
        "www\\\\.capitalfm\\\\.com": "www.capitalfm.development.int.thisisglobal.com"
    }
    EOF

    SQUID_CONF_SOURCE=/usr/local/etc/squid.conf
    SQUID_CONF=./squid.conf
    cp ${SQUID_CONF_SOURCE} ${SQUID_CONF}

    cat <<EOF >> ${SQUID_CONF}

    url_rewrite_children 3 startup=0 idle=1 concurrency=1
    url_rewrite_extras ""
    url_rewrite_program /usr/local/bin/python3 $(pwd)/squid-redirect.py --rewrite $(pwd)/rules.json
    EOF

    squid -N -f ${SQUID_CONF}

3.) Setup osx transparent webproxy.

Programs that respect webproxy:

  • chrome
  • ios_simulator

webproxy is not sufficient for system-level programs like:

  • firefox
  • curl
    NETWORK_DEVICE="Wi-Fi"
    PROXY_HOST="localhost"
    PROXY_PORT="3128"
    networksetup -setwebproxy ${NETWORK_DEVICE} ${PROXY_HOST} ${PROXY_PORT}
    networksetup -setsecurewebproxy ${NETWORK_DEVICE} ${PROXY_HOST} ${PROXY_PORT}

    networksetup -setwebproxy ${NETWORK_DEVICE} "" ""
    networksetup -setsecurewebproxy ${NETWORK_DEVICE} "" ""
    networksetup -setwebproxystate ${NETWORK_DEVICE} off
    networksetup -setsecurewebproxystate ${NETWORK_DEVICE} off

References

Squid Documentation

Alternate Example Implementations of url_rewrite_program

squid-redirect's People

Contributors

calaldees avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.