设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 重新 试卷 文件
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

windows-server-2008 – 让squid通过kerberos和Windows 2008/200(2)

发布时间:2021-02-21 07:03 所属栏目:117 来源:网络整理
导读:设置用户和目录: $chown -R squid:squid /opt/squid-3.0/$mkdir /var/cache/squid-3.0$chown -R squid:squid /var/cache/$mkdir /var/log/squid-3.0$chown -R squid:squid /var/log/squid-3.0/$chown squid:squid

设置用户和目录:

$chown -R squid:squid /opt/squid-3.0/
$mkdir /var/cache/squid-3.0
$chown -R squid:squid /var/cache/
$mkdir /var/log/squid-3.0
$chown -R squid:squid /var/log/squid-3.0/
$chown squid:squid /etc/HTTP.keytab

创建缓存:

$/opt/squid-3.0/sbin/squid -z

初始化脚本

现在这很重要:Squid需要一些环境变量设置才能正常运行.执行此操作的最佳方法是使用init脚本.这是一个略有编辑的CentOS:

#!/bin/bash
# squid     This shell script takes care of starting and stopping
#       Squid Internet Object Cache
#
# chkconfig: - 90 25
# description: Squid - Internet Object Cache. Internet object caching is \
#   a way to store requested Internet objects (i.e.,data available \
#   via the HTTP,FTP,and gopher protocols) on a system closer to the \
#   requesting site than to the source. Web browsers can then use the \
#   local Squid cache as a proxy HTTP server,reducing access time as \
#   well as bandwidth consumption.
# pidfile: /var/run/squid-3.0.pid
# config: /opt/squid-3.0/etc/squid.conf

PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# don't raise an error if the config file is incomplete
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-"-D"}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}

KRB5_KTNAME=/etc/HTTP.keytab
export KRB5_KTNAME

# determine the name of the squid binary
[ -f /opt/squid-3.0/sbin/squid ] && SQUID=/opt/squid-3.0/sbin/squid

prog="$SQUID"

# determine which one is the cache_swap directory
CACHE_SWAP=`sed -e 's/#.*//g' /opt/squid-3.0/etc/squid.conf | \
    grep cache_dir |  awk '{ print $3 }'`
[ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/spool/squid-3.0

RETVAL=0

start() {

        #check if the squid conf file is present
        if [ ! -f /opt/squid-3.0/etc/squid.conf ]; then
            echo "Configuration file /opt/squid-3.0/etc/squid.conf missing" 1>&2
            exit 6
        fi
        . /etc/sysconfig/squid

        # don't raise an error if the config file is incomplete.
        # set defaults instead:
        SQUID_OPTS=${SQUID_OPTS:-"-D"}
        SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
        SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}

        if [ -z "$SQUID" ]; then
                echo "Insufficient privilege" 1>&2
                exit 4
        fi

        for adir in $CACHE_SWAP; do
        if [ ! -d $adir/00 ]; then
         echo -n "init_cache_dir $adir... "
         $SQUID -z -F -D >> /var/log/squid-3.0/squid.out 2>&1
    fi
    done
    echo -n $"Starting $prog: "
    $SQUID $SQUID_OPTS >> /var/log/squid-3.0/squid.out 2>&1
    RETVAL=$?
    if [ $RETVAL -eq 0 ]; then
       timeout=0;
       while : ; do
          [ ! -f /var/run/squid-3.0.pid ] || break
      if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
         RETVAL=1
         break
      fi
      sleep 1 && echo -n "."
      timeout=$((timeout+1))
       done
    fi
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/squid-3.0
    [ $RETVAL -eq 0 ] && echo_success
    [ $RETVAL -ne 0 ] && echo_failure
    echo
    return $RETVAL
}

stop() {
    . /etc/sysconfig/squid

    # don't raise an error if the config file is incomplete.
    # set defaults instead:
    SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}

    echo -n  $"Stopping $prog: "
    $SQUID -k check >> /var/log/squid-3.0/squid.out 2>&1
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
        $SQUID -k shutdown &
        rm -f /var/lock/subsys/squid-3.0
    timeout=0
    while : ; do
        [ -f /var/run/squid-3.0.pid ] || break
        if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
            echo
            return 1
        fi
        sleep 2 && echo -n "."
        timeout=$((timeout+2))
        done
    echo_success
    echo
    else
        echo_failure
    echo
    fi
    return $RETVAL
}

reload() {
    . /etc/sysconfig/squid
    # don't raise an error if the config file is incomplete.
    # set defaults instead:
    SQUID_OPTS=${SQUID_OPTS:-"-D"}

    $SQUID $SQUID_OPTS -k reconfigure
}

restart() {
    stop
    start
}

condrestart() {
    [ -e /var/lock/subsys/squid-3.0 ] && restart || :
}

rhstatus() {
    status $SQUID && $SQUID -k check
}

probe() {
    return 0
}

case "$1" in
start)
    start
    ;;

stop)
    stop
    ;;

reload)
    reload
    ;;

restart)
    restart
    ;;

condrestart)
    condrestart
    ;;

status)
    rhstatus
    ;;

probe)
    exit 0
    ;;

*)
    echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
    exit 2
esac

exit $?

这些是重要的路线:

KRB5_KTNAME=/etc/HTTP.keytab
export KRB5_KTNAME

客户端机器

使用端口3128将代理设置为服务器centos.dom.local.使用完全限定的域名而不是IP地址非常重要.

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读