GithubHelp home page GithubHelp logo

stefrave / transparent-proxy-with-squid3-and-vagrant Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yanhaoyang/transparent-proxy-with-squid3-and-vagrant

0.0 3.0 0.0 83 KB

Setup a transparent proxy with squid3 and vagrant

License: MIT License

transparent-proxy-with-squid3-and-vagrant's Introduction

Transparent proxy in Vagrant

When you play with Vagrant boxes or Dockers, a lot of files will be downloaded from internet again and again. For example, every time you run apt-get update, it will download a set of files. The setup process will be much faster if these files can be cached in local network. In this case, a transparent proxy can be very helpful.

How it works

Two Vagrant boxes will be created. Squid 3 is install in one box called squid, and another box called client, is an example to demonstrate how to use the proxy.

The "squid" box has two NICs. The default NIC is used to access internet, while a private_network with IP address 172.28.128.200 will be the gateway of clients.

After these boxes are up, you need to login the client box, change the default gateway with command change-gateway, then most HTTP request will be cached.

Route table can be verified with this command, netstat -r:

root@client:~# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         localhost       0.0.0.0         UG        0 0          0 eth1
10.0.2.0        *               255.255.255.0   U         0 0          0 eth0
172.28.128.0    *               255.255.255.0   U         0 0          0 eth1

To check if the proxy is working, initiate some HTTP requests from "client" box:

curl -v http://bing.com
curl -v http://bing.com

There will be following content in /var/log/squid3/access.log on "squid" box:

vagrant@squid:~$ sudo tail -f /var/log/squid3/access.log
1446885198.469    784 172.28.128.202 TCP_MISS/301 395 GET http://bing.com/ - HIER_DIRECT/204.79.197.200 -
1446885203.531      1 172.28.128.202 TCP_MEM_HIT/301 401 GET http://bing.com/ - HIER_NONE/- -

Enjoy it!


See the certificate returned for https connections
curl --insecure -v https://www.bing.com 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }'

Get & restort with new config
sudo cp /vagrant/files/squid.conf /etc/squid/squid.conf
sudo squid -k reconfigure

Up & running?
netstat -an |grep 3130

sudo tail -f /var/log/squid/cache.log
sudo tail -f /var/log/squid/access.log

Usefull SSL docs

http://wiki.squid-cache.org/Features/SslPeekAndSplice http://marek.helion.pl/install/squid.html (not tried yet)

transparent-proxy-with-squid3-and-vagrant's People

Contributors

stefrave avatar yanhaoyang avatar

Watchers

 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.