Vagrant configuration file for PXaaS vnf development environment for T-NOVA project.
It deploys a Debian Wheezy server and builds a Squid proxy, SquidGuard and a Dashboard on it.
The idea behind PXaaS vnf is to enables a user, who acts as the network administrator of his LAN, to configure the Squid Proxy on demand and provide Proxy services such as web caching, web access control, website filtering and user anonymity to the LAN's users.
Install
Install Vagrant plugins
vagrant-useraddandvagrant-vbguestsudo vagrant plugin install vagrant-useradd sudo vagrant plugin install vagrant-vbguest
The
vagrant-useraddplugin enables Vagrant to create users in the VM, before setting up file sharing.The
vagrant-vbguestplugin makes sure that whenever we runvagrant up, the correct version ofVirtualBox Guest Additionswill be installed.
Create the folder
devand cd into itmkdir dev cd devClone the
proxy-buildrepository, and cd into the foldergit clone git@github.com:dimosthe/proxy-build.git cd proxy-buildCreate the folder
sharedmkdir shared
This folder will expose some application files and folders to the host filesystem.
[Optional] If you want to change the VM's default IP, edit the
Vagrantfileand modify the IP defined in lineconfig.vm.network :private_network, ip: "192.168.56.120"
For the rest of the documentation, we'll assume that the IP is 192.168.56.120
Create and run the VM
vagrant up
Once this command finishes, the VM is up and running. Our user is vagrant and password vagrant. The VM is bound to the local IP 192.168.56.120.
- Now you can use command
vagrant sshto SSH into the VM, without providing any password.
Install necessary packages
- apache2
- mysql-server-5.5
- git
- curl
- php5
- php5-curl
- php5-intl
- php5-mcrypt
- php5-mysql
- php5-imagick
- libapache2-mod-php5
- python-pip
Generate SSH keys for the user
proxyvnfin order to use theSquid-dashboardrepository. Firstly change to userproxyvnfsudo -u proxyvnf -s
and follow the instructions above
Clone the
Squid-dashboardcd /home/proxyvnf/dashboard git clone git@github.com:dimosthe/Squid-dashboard.git
Create a new database and a new user
mysql -u root -p create database dashboarddb create user 'dashboarduser'@'localhost' identified by '12345678'; grant all privileges on dashboarddb.* to dashboarduser@localhost; vim config/db.php // edit the file accordingly
Install Composer
curl -s http://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
Run
composer global require "fxp/composer-asset-plugin:~1.1.0". Installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all.Run
composer installin the root directory of theSquid-dashboardapplication in order to install dependencies. This will create the vendor directory with all package dependencies inlcuding the yii core source code.Install Squid 3.5.5 and SquidGuard (see intructions at the end of the page)
Install migrations. Run the following commands from the application's root directory
sudo -u proxyvnf -s php yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations // in order to build the tables for the yii2-user module ./yii createusers/create // from the root of the application. It creates a default user with username:admin, pass:administrator ./yii migrate // to install other migrations
Enable apache rewrite module
sudo a2enmod rewrite sudo service apache2 restart
Create a symlink to point to the
Squid-dashboardapplicationcd /var/www/html sudo ln -s /home/proxyvnf/dashboard/Squid-dashboard/ dashboard
Set document root to be
/var/www/html/dashboard/websudo vim /etc/apache2/sites-available/000-default.conf DocumentRoot "/var/www/html/dashboard/web"
Hide
index.phpfrom the urlsudo vim /etc/apache2/apache2.conf <Directory "/var/www/html/dashboard/web"> # use mod_rewrite for pretty URL support RewriteEngine on # If a directory or a file exists, use the request directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Otherwise forward the request to index.php RewriteRule . index.php
# ...other settings...Allow apache2 to run sudo without providing password. This is usefull when execute commands on Squid via the dashboard
sudo touch /etc/sudoers.d/www-data sudo vim /etc/sudoers.d/www-data www-data ALL=(ALL) NOPASSWD:ALL // add this line in the file
Test the application
vagrant halt
vagrant package
Creates a package.box
Add the box to Vagrant in order to be able to build VMs from it
vagrant box add <path-to-package.box> vagrant box list # to check if the box is listed
Create the folder
devand cd into itmkdir dev cd dev
Clone the
proxy-buildrepository, and cd into the foldergit clone git@github.com:dimosthe/proxy-build.git cd proxy-buildChange the name of the box (as specified in (1)) in
Vagrantfileconfig.vm.box = ""
Create the folder
sharedmkdir shared
This folder will expose some application files and folders to the host filesystem.
Create and run the VM
vagrant up
Once this command finishes, the VM is up and running. Our user is vagrant and password vagrant. The VM is bound to the local IP 192.168.56.120.
Now you can use command
vagrant sshto SSH into the VM, without providing any password.There is an issue with the synced folder. The content is lost after deploying the VM so we need to clone the
Squid-dashboardapplication againsudo -u proxyvnf -s
Generate SSH keys and add the public key to your git profile
cd /home/proxyvnf/dashboard git clone git@github.com:dimosthe/Squid-dashboard.git cd Squid-dashboard composer install
Test the application
We build Squid 3.5.5 from source code
* g++
* make
* autoconf
* apache2-utils
Download source code, extract and cd into it
Run
./configure --prefix=/usr --localstatedir=/var --libexecdir=${prefix}/lib/squid --srcdir=. --datadir=${prefix}/share/squid --sysconfdir=/etc/squid --with-default-user=proxy --with-logdir=/var/log/squid --with-pidfile=/var/run/squid.pid --enable-delay-pools --enable-auth-basic=DB,NCSA --enable-cache-digests --disable-arch-native
make sudo make install
Build
service squid start.Add
basic_db_authplugin under /usr/lib/squid3 directory # it is used for authenticationRun
service squid start
Install squidguard
sudo apt-get install squidguard
The problem is that squid3 is also installed when running the above command and starts on start-up. In order to disable the service on start-up:
sudo update-rc.d -f squid3 remove sudo reboot
Initializing the blacklists
sudo squidGuard -C all # convert them from the textfiles to db files. Note that only domains that are defined in the configuration file will be converted sudo chown -R proxy:proxy /etc/squidguard/blacklists/* # ensures that squid is able to access the blacklists
Configuring Squid
redirect_program /usr/bin/squidGuard -c /etc/squidguard/squidGuard.conf # at the beginning of squid.conf
# [optional] Convert vmdk to qcow2
qemu-img convert -f vmdk -O qcow2 image.vmdk image.qcow2
# Unistall VirtualBox GuestAdditions sudo /opt/[VboxAddonsFolder]/uninstall.sh