#!/bin/bash

# need to be run as root
 ]]; then
    echo "must to be run as root"
    exit
fi

# giving user passwordless sudo privileges
who=`whoami`
myhomepath=$(cat /etc/passwd|grep $who|awk -F: '{print $6}')

# receive specific port from cmd,
PORT=${:-}

#install package
sudo apt-get install -y squid stunnel

# generate key, including client & server
cd /etc/stunnel

openssl req -new -x509 -days  -batch -nodes -config /usr/share/doc/stunnel4/examples/stunnel.cnf -out server.pem -keyout server.pem
openssl req -new -x509 -days  -batch -nodes -config /usr/share/doc/stunnel4/examples/stunnel.cnf -out client.pem -keyout client.pem

# modify (if not exist, will create) stunnel config
sudo cat <<EOF >/etc/stunnel/stunnel.conf
chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /stunnel4.pid
debug =
output = stunnel.log

cert = /etc/stunnel/server.pem
#sslVersion = SSLv3

verify =
CAfile = /etc/stunnel/client.pem

socket = r:TCP_NODELAY=
socket = l:TCP_NODELAY=

[squid]
accept = $PORT
connect =
EOF

# config squid
sudo sed -i -r "s/^#acl localnet src 10.0.0.0/acl localnet src 10.0.0.0/g" /etc/squid3/squid.conf
sudo sed -i -r "s/^#acl localnet src 172.16.0.0/acl localnet src 172.16.0.0/g" /etc/squid3/squid.conf
sudo sed -i -r "s/^#acl localnet src 192.168.0.0/acl localnet src 192.168.0.0/g" /etc/squid3/squid.conf
sudo sed -i -r "s/^#acl localnet src fc00::/acl localnet src fc00::/g" /etc/squid3/squid.conf
sudo sed -i -r "s/^#acl localnet src fe80::/acl localnet src fe80::/g" /etc/squid3/squid.conf
sudo sed -i -r "/acl Safe_ports port 777/a acl SSL_ports port 443 6667 7709 143 993 585 5223 29418 \\n" /etc/squid3/squid.conf
sudo sed -i -r "/acl CONNECT method CONNECT/a acl irc_port port 6667\\nacl irc dstdomain irc.freenode.net\\nhttp_access allow irc irc_port \\n" /etc/squid3/squid.conf

# important...
sed -i -r "s/ENABLED=0/ENABLED=1/g" /etc/default/stunnel4

# restart service
sudo service stunnel4 restart

stunnel-server的更多相关文章

  1. Stunnel使用2

    1.首先测试一下stunnel.exe,是否能正常运行,正常的话,不会报错,在桌面右下角位置显示. 2.第一步完成后,打开stunnel.conf,对stunnel进行配置,需要修改一下几项:(mys ...

  2. (转)用stunnel给普通http通信加密

    转自:https://www.digitalocean.com/community/tutorials/how-to-set-up-an-ssl-tunnel-using-stunnel-on-ubu ...

  3. 【原】基于64位Centos6.2的mcrouter使用简介

    此文转载必须注明原文地址,请尊重作者的劳动成果!  http://www.cnblogs.com/lyongerr/p/5040071.html 目录 文档控制... 2 1 mcrouter简介.. ...

  4. Windows系统Stunnel客户端的配置

    Stunnel官方就有Windows版本,到下面的地址下载: https://www.stunnel.org/downloads.html 选择”stunnel-X.XX-installer.exe“ ...

  5. Stunnel服务端

    Stunnel on Debian GNU/Linux 6 (squeeze) 传统的POP3, SMTP, Samba等服务,都是不加密的协议(即在网络上明文传输数据),通过stunnel,可以将访 ...

  6. Stunnel使用

     建立加密隧道 使用 Stunnel 建立加密隧道 附件中的 Server 和 Clinet 都是已经配置好了的,只需修改 Server 的 stunnel.conf 的 connect 为实际的ip ...

  7. 常用工具之stunnel

    The stunnel program is designed to work as an SSL encryption wrapper between remote client and local ...

  8. 安装Stunnel来实现正向代理邮件

    文:铁乐与猫 2017年8月 一开始我是使用yum install来安装stunnel的 感觉版本低点也无所谓,毕竟只是拿来加密代理一下邮件收发. 可是后来发现之前下载的最新官网版本的tar包里有很多 ...

  9. linux下使用Stunnel配置与使用方式一例

    第一部分:stunnel的安装与配置 注:在ubuntu下,stunnel的安装很简单快捷. 在synaptic(安立得工具系统下可以直接选举安装) 在服务器环境下,直接使用apt-get insta ...

随机推荐

  1. 100. Same Tree

    [题目] Given two binary trees, write a function to check if they are equal or not. Two binary trees ar ...

  2. Retrofit源码研究

    2016-05-06 15:35:27 最近抽空研究了一下Retrofit源码,包括API使用.源码结构.使用到的设计模式.SDK的架构设计.作者设计/实现思路等,会形成一系列文章. 以前Retrof ...

  3. Bootstrap<基础二十七> 多媒体对象(Media Object)

    Bootstrap 中的多媒体对象(Media Object).这些抽象的对象样式用于创建各种类型的组件(比如:博客评论),我们可以在组件中使用图文混排,图像可以左对齐或者右对齐.媒体对象可以用更少的 ...

  4. Java String.split()小点

    java String.split(); 别的不说,单说其中一个问题,这个函数去切分空字符串时,得到的结果: public static void main(String[] args) {// St ...

  5. 更改mysql中当前auto_increment的值的方法

    最近给自己网站更改mysql中当前auto_increment的值 如果在mysql中一个表test中的ID字段设为auto_increment插入两条记录后ID=2,这时删除1条记录,再插入一条变成 ...

  6. 应用jacob组件造成的内存溢出解决方案(java.lang.OutOfMemoryError: Java heap space)

    http://www.educity.cn/wenda/351088.html 使用jacob组件造成的内存溢出解决方案(java.lang.OutOfMemoryError: Java heap s ...

  7. JPA原理理解

    从前面一篇<JPA使用入门>了解了JPA的简单使用.要想继续深入的使用JPA,可能了解一点原理对于学习JPA会比较有益处. 这里从JPA的功能来简单阐述JPA的原理. 从<初步了解J ...

  8. RecyclerView因版本问题无法加载

    前几天在学习RecyclerView时候,一直失败,各种加载不上.下面是错误信息 D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL ...

  9. 如何解决Selenium中"Cannot find function addEventListener in object [object HTMLDocument]"的错误

    project: blog target: how-to-resolve-cannot-find-function-addEventListener-error-in-selenium.md stat ...

  10. 北大poj- 1045

    Bode Plot Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14060   Accepted: 8820 Descri ...