Good. Lets start :)
Try this, should work for you.
First, solution is based on squid.
After installation, obviously, we’ll be modifying the squid.conf
file. We’ll be using the following configuration directives:
http_port
name=
myportname
acl
http_access
tcp_outgoing_address
First, we want to tell Squid what IPs and ports to listen on, and we want to use the name=
option with http_port
:
# Squid normally listens to port 3128
http_port xx.xxx.xxx.111:3128 name=3128
http_port xx.xxx.xxx.112:3129 name=3129
http_port xx.xxx.xxx.113:3130 name=3130
http_port xx.xxx.xxx.114:3131 name=3131
http_port xx.xxx.xxx.115:3132 name=3132
http_port xx.xxx.xxx.116:3133 name=3133
We just asked Squid to listen on sequential ports and to designate a name for each inbound connection. Now that we’ve named the inbound connections, we can designate an ACL
based on each inbound connection name and assign an outgoing IP
to each:
acl tasty3128 myportname 3128 src yy.yyy.yyy.0/24
http_access allow tasty3128
tcp_outgoing_address xx.xxx.xxx.111 tasty3128
acl tasty3129 myportname 3129 src yy.yyy.yyy.0/24
http_access allow tasty3129
tcp_outgoing_address xx.xxx.xxx.112 tasty3129
acl tasty3130 myportname 3130 src yy.yyy.yyy.0/24
http_access allow tasty3130
tcp_outgoing_address xx.xxx.xxx.113 tasty3130
acl tasty3131 myportname 3131 src yy.yyy.yyy.0/24
http_access allow tasty3131
tcp_outgoing_address xx.xxx.xxx.114 tasty3131
acl tasty3132 myportname 3132 src yy.yyy.yyy.0/24
http_access allow tasty3132
tcp_outgoing_address xx.xxx.xxx.115 tasty3132
acl tasty3133 myportname 3133 src yy.yyy.yyy.0/24
http_access allow tasty3133
tcp_outgoing_address xx.xxx.xxx.116 tasty3133
That’s it. You should now be able to connect to any configured IP addresses through Squid.
In example I use only 6 ip.
Next. If you wish basic authentication you must do following
We are going to create a file to store passwords in it and change the ownership of it so Squid can access.
sudo touch /etc/squid/passwd
sudo chown squid /etc/squid/passwd
Suppose that john
is our username for accessing the Squid proxy server, we will use this command to generate password for that username. You will need to type the password and retype it again for confirmation.
The -d
argument in this command will force the htpasswd
to use CRYPT
encryption of the password.
sudo htpasswd -d /etc/squid/squid_passwd john
New password:
Re-type new password:
Adding password for user john
To test if the username and password type this command and in the following file enter the username and password seprated by space.
/usr/lib64/squid/ncsa_auth /etc/squid/passwd
john pass
OK
Open the Squid configuration file and add following lines to the top of file.
auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/passwd
auth_param basic children 5
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users
https_access allow ncsa_users
After changes restart service
sudo service squid restart
Try.