代理服务器怎么设置完全访问网络权限密码「代理服务器怎么设置完全访问网络权限密码」

代理服务器是一种位于客户端和目标服务器之间的中间服务器,它的主要功能是转发客户端的请求到目标服务器,并将目标服务器的响应返回给客户端,在某些情况下,我们可能需要设置代理服务器的访问权限密码,以确保只有知道密码的人才能访问网络,如何设置代理服务器的完全访问网络权限密码呢?本文将详细介绍这个过程。

代理服务器怎么设置完全访问网络权限密码「代理服务器怎么设置完全访问网络权限密码」

我们需要了解代理服务器的类型,代理服务器主要分为两种类型:透明代理和匿名代理,透明代理是指客户端不需要设置任何代理配置,只需要将请求发送到代理服务器即可;而匿名代理则需要客户端设置代理服务器的地址和端口,以便将请求发送到正确的位置,在设置代理服务器的访问权限密码时,我们需要根据代理服务器的类型来选择合适的方法。

对于透明代理,我们可以使用Squid这个开源的代理服务器软件来实现,Squid支持多种认证方式,包括用户名/密码认证、NTLM认证等,我们将介绍如何使用用户名/密码认证来设置透明代理的访问权限密码。

1. 安装Squid

我们需要在服务器上安装Squid,在Ubuntu系统中,可以使用以下命令安装:

sudo apt-get update
sudo apt-get install squid

2. 配置Squid

安装完成后,我们需要对Squid进行配置,配置文件位于`/etc/squid/squid.conf`,打开配置文件,找到以下两行:

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic children 5

这两行配置了Squid的基本认证方式和子进程数量,`/usr/lib/squid/basic_ncsa_auth`是一个用于处理基本认证的程序,`/etc/squid/passwords`是一个存储用户名和密码的文件,我们需要修改这两个文件来实现访问权限密码的设置。

3. 创建用户列表文件

在`/etc/squid/`目录下创建一个名为`users.txt`的文件,用于存储允许访问代理服务器的用户列表,每行一个用户名,例如:

user1
user2
user3

4. 创建密码文件

在`/etc/squid/passwords`文件中添加允许访问代理服务器的用户及其对应的密码,每行一个用户和密码,格式为:用户名:密码。

user1:password1
user2:password2
user3:password3

5. 重启Squid服务

保存配置文件后,重启Squid服务以使更改生效:

sudo systemctl restart squid

我们已经完成了透明代理的访问权限密码设置,客户端无需进行任何特殊配置,只需将请求发送到代理服务器即可,如果客户端需要使用用户名和密码进行认证,可以在浏览器或命令行中输入以下信息:

http_proxy=http://代理服务器地址:端口 username=用户名 password=密码

对于匿名代理,我们可以使用Privoxy这个开源的代理服务器软件来实现,Privoxy同样支持多种认证方式,包括HTTP基本认证、摘要认证等,我们将介绍如何使用HTTP基本认证来设置匿名代理的访问权限密码。

1. 安装Privoxy

我们需要在服务器上安装Privoxy,在Ubuntu系统中,可以使用以下命令安装:

sudo apt-get update
sudo apt-get install privoxy

2. 配置Privoxy

安装完成后,我们需要对Privoxy进行配置,配置文件位于`/etc/privoxy/config`,打开配置文件,找到以下两行:

forward-socks5t / localhost:9050 . 
allow-transport = socks5 tcp
allow-nonstd {tcp,http} -msnprintf {"%s", "[::]:%u";} 
cache-peer localhost parent 8080 0 no-query default 

这两行配置了Privoxy的监听地址和端口,我们需要修改这些配置来实现访问权限密码的设置,还需要启用HTTP基本认证功能,在配置文件中找到以下行:

```ini

#enable-feature = "setenvif"

#setenv = "no-cache:$request_method"

#setenv = "no-store:$request_method"

#setenv = "cache-control:no-store, max-age=0, no-cache, must-revalidate"

#setenv = "pragma:no-cache"

#setenv = "proxy-revalidate"

#setenv = "connection: close"

#setenv = "keep-alive: timeout=15, max=100"

#setenv = "server: $http_host"

代理服务器怎么设置完全访问网络权限密码「代理服务器怎么设置完全访问网络权限密码」

#setenv = "date: $time_local"

#setenv = "content-type: $content_type"

#setenv = "mime-version: $mime_version"

#setenv = "x-powered-by: PHP/$php_version"

#setenv = "x-served-by: $hostname"

#setenv = "x-clientip: $remote_addr"

#setenv = "x-forwardedfor: $proxy_add_x_forwarded_for"

#setenv = "x-forwardedproto: $scheme"

#decorateresponse on

#decoraterequest on

#accesslog off

#logformat raw '$raw_request'

#logformat urlencoded '$url_decoded'

#debugfile "/var/log/privoxy/access.log"

#debugfile "/var/log/privoxy/error.log"

#debugoptions +Epd,+Upd,+Ntf,+Dcr,+Icu,+Ccd,+Ubu,+Rdb,+Mbc,+Alc,+Fsc,+Lmc,+Otc,+Rfc,+Wmc,+Xmc,+Zmc,+Bmc,+Pmc,+Qmc,+Tmc,+Ymc,+Kmc,+Jmc,+Gmc,+Hmc,+Imc,+Imcv,+Imdv,+Imbv,+Imdw,+Imfw,+Imsw,+Imtw,+Imtx,+Imrx,+Imry,+Imrz,+Imsz,+Imtz,+Imsbv,+Imsbw,+Imsbx,+Imsby,+Imsbz

#debugoptions -Ftq

#filterfile "/etc/privoxy/user.action"

#filterfile "/etc/privoxy/default.action"

#filterfile "/etc/privoxy/trust.action"

#filterfile "/etc/privoxy/badfilter.action"

#filterfile "/etc/privoxy/user.filter"

#filterfile "/etc/privoxy/default.filter"

#filterfile "/etc/privoxy/trust.filter"

#filterfile "/etc/privoxy/badfilter.filter"

#persistent_cookies on

#persistent_login off

#ignore_canonical on

listen-address 0.0.0.0:8118

## HTTP Basic Access authentication

代理服务器怎么设置完全访问网络权限密码「代理服务器怎么设置完全访问网络权限密码」

##

## Uncomment and edit the following line to specify the file containing the users

## and their passwords:

acl purge method PURGE http://*/*

acl purge method PURGE https://*/*

acl allow method CONNECT http://*/*

acl allow method CONNECT https://*/*

acl allow proxy

acl allow SOCKS5

acl allow SOCKS4a

acl deny all

acl check_user passwd.txt

acl check_group passwd.txt

acl check_ip passwd.txt

acl check_request_hdr host passwd.txt

acl check_request_hdr user-agent passwd.txt

acl check_request_hdr referer passwd.txt

acl check_request_hdr accept passwd.txt

acl check_request_hdr connection passwd.txt

acl allow localnet

acl allow localhost

acl allow external

acl allow ICMP

acl allow UDP

acl allow TCP

acl allow SSH

acl allow MSNMSGS

acl allow RTP\brownlist deny brownlist\brownlist deny blacklist\brownlist deny whitelist\brownlist deny badwords\brownlist deny bannedsites\brownlist deny bannedips\brownlist deny bannedemails

原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/17372.html

(0)
K-seoK-seoSEO优化员
上一篇 2023年11月12日 22:12
下一篇 2023年11月12日 22:16

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

免备案 高防CDN 无视CC/DDOS攻击 限时秒杀,10元即可体验  (专业解决各类攻击)>>点击进入