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-useradd
andvagrant-vbguest
sudo vagrant plugin install vagrant-useradd sudo vagrant plugin install vagrant-vbguest
The
vagrant-useradd
plugin enables Vagrant to create users in the VM, before setting up file sharing.The
vagrant-vbguest
plugin makes sure that whenever we runvagrant up
, the correct version ofVirtualBox Guest Additions
will be installed.
-
Create the folder
dev
and cd into itmkdir dev cd dev
-
Clone the
proxy-build
repository, and cd into the foldergit clone [email protected]:dimosthe/proxy-build.git cd proxy-build
-
Create the folder
shared
mkdir 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
Vagrantfile
and 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 ssh
to 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
proxyvnf
in order to use theSquid-dashboard
repository. Firstly change to userproxyvnf
sudo -u proxyvnf -s
and follow the instructions above
-
Clone the
Squid-dashboard
cd /home/proxyvnf/dashboard git clone [email protected]: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 install
in the root directory of theSquid-dashboard
application 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-dashboard
applicationcd /var/www/html sudo ln -s /home/proxyvnf/dashboard/Squid-dashboard/ dashboard
-
Set document root to be
/var/www/html/dashboard/web
sudo vim /etc/apache2/sites-available/000-default.conf DocumentRoot "/var/www/html/dashboard/web"
-
Hide
index.php
from 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
dev
and cd into itmkdir dev cd dev
-
Clone the
proxy-build
repository, and cd into the foldergit clone [email protected]:dimosthe/proxy-build.git cd proxy-build
-
Change the name of the box (as specified in (1)) in
Vagrantfile
config.vm.box = ""
-
Create the folder
shared
mkdir 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 ssh
to 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-dashboard
application againsudo -u proxyvnf -s
Generate SSH keys and add the public key to your git profile
cd /home/proxyvnf/dashboard git clone [email protected]: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_auth
plugin under /usr/lib/squid3 directory # it is used for authentication -
Run
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