1,环境介绍:
OS:CentOS Linux release 7.6.1810 (Core)
tinyproxy 版本:Release 1.11.1 ps:1.10版本后支持设置用户密码,类似squid
2,安装步骤,配置文件,启动:
官网及下载地址:
https://github.com/tinyproxy/tinyproxy
https://github.com/tinyproxy/tinyproxy/releases/tag/1.11.1
https://github.com/tinyproxy/tinyproxy/releases/download/1.11.1/tinyproxy-1.11.1.tar.gz
wget https://github.com/tinyproxy/tinyproxy/releases/download/1.11.1/tinyproxy-1.11.1.tar.gz
解压,安装:
tar xvpf tinyproxy-1.11.1.tar.gz
cd tinyproxy-1.11.1
./autogen.sh
./configure
make
make install
执行后会产生可执行程序:/usr/local/bin/tinyproxy 配置文件:/usr/local/etc/tinyproxy/tinyproxy.conf
默认的配置文件可以不管,我们创建自定义的配置文件 tinyproxy.conf,只需要简单配置几个核心参数即可:
mkdir /etc/tinyproxy/
vi /etc/tinyproxy/tinyproxy.conf
# 用户和组
User nobody
Group nobody
# 监听端口
Port 8888
# 在多网卡的情况下,设置出口 IP 是否与入口 IP 相同。默认情况下是关闭的
BindSame yes
# 超时时间
Timeout 30
# 这个地方建议建立一个空文件给到报错时读取的文件模板,默认的模板会打印tinyproxy等信息,其他人可以通过输入错误认证信息得到tinyproxy代理服务名字,版本等。
DefaultErrorFile "/usr/local/share/tinyproxy/default_nooutput.html"
#DefaultErrorFile "/usr/local/share/tinyproxy/default.html"
#该选项配置被当作统计主机的主机名或者IP地址:每当收到对该主机的请求时,Tinyproxy 会返回内部统计信息页面,而不会将请求转发给该主机。此页面的模板可以使用 StatFile 配置项进行配置。StatHost 的默认值为 tinyproxy.stats。
StatHost "127.0.0.1"
StatFile "/usr/local/share/tinyproxy/stats.html"
# 指定日志位置
LogFile "/var/log/tinyproxy/tinyproxy.log"
LogLevel Info
# 设置最大客户端链接数
MaxClients 1024
#RFC 2616 要求代理将 Via 标头添加到 HTTP 请求中,但使用真实主机名可能会引起安全问题。 如果设置了 ViaProxyName 选项,其字符串值将用作 Via 标头中的主机名。 否则,将使用服务器的主机名。
ViaProxyName "baidu"
# 将此选项设置为Yes将通知Tinyproxy将包含客户端IP地址的标头X-Tinyproxy添加到请求中。
# 如果是yes 则在header头中会添加原始ip,非高匿名模式,默认是 no
# 如果是yes 代理提交出去的header中会包含:"X-Tinyproxy": "127.0.0.1"
XTinyproxy no
# 该选项设置为 yes 时,Tinyproxy 不会将 Via 标头添加到请求中。 这实际上就使 Tinyproxy 进入了隐身模式。请注意,RFC 2616 要求代理设置 Via 头,因此启用此选项会破坏合规性。 除非您知道自己在做什么,否则不要禁用 Via 标头...
# 默认是 no ,遵循了RFC 2616协议,代理需要带上头说明自己是代理服务过来的请求
# 如果是 no 代理提交出去的header中会包含:"Via": "1.1 xxxx (tinyproxy/1.11.1)"
DisableViaHeader yes
#以上两条修改后就能做到高匿名
# 权限校验
BasicAuth xxx yyy
设置启动脚本:
vi /usr/bin/tp
#!/bin/bash
if [ $# -lt 1 ]
then
echo "No Args Input..."
exit ;
fi
case $1 in
"start")
echo " =================== 启动 ==================="
nohup tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf > /dev/null 2>&1 &
;;
"stop")
echo " =================== 关闭 ==================="
ps -ef|grep tinyproxy|grep -v grep|awk '{print "kill -9 "$2}'|sh
;;
"restart")
echo " =================== 重启 ==================="
ps -ef|grep tinyproxy|grep -v grep|awk '{print "kill -9 "$2}'|sh
nohup tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf > /dev/null 2>&1 &
;;
"status")
echo " =================== 状态 ==================="
ps -ef|grep tinyproxy|grep -v grep
;;
*)
echo "Input Args Error..."
;;
esac
设置权限:
chmod 777 /usr/bin/tp
启动控制:
tp start
tp stop
tp status
tp restart
查看日志:
tail -f /var/log/tinyproxy/tinyproxy.log
3,正式测试:
在另一台公网ip机器上用curl测试,成功没有显示任何代理信息,真正做到了http协议的 高匿名+账号密码验证 代理服务:
curl -x http://xxx:yyy@xxx.xxx.xxx.xxx:8888 http://httpbin.org/get?show_env=1
{
"args": {
"show_env": "1"
},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/7.29.0",
"X-Amzn-Trace-Id": "Root=2-6361231232a-2a123d67c1231231231644946e55a",
"X-Forwarded-For": "xxx.xxx.xxx.xxx",
"X-Forwarded-Port": "80",
"X-Forwarded-Proto": "http"
},
"origin": "xxx.xxx.xxx.xxx",
"url": "http://httpbin.org/get?show_env=1"
}
设置无需认证的代理,则把 tinyproxy.conf的最后一行注释即可。
BasicAuth xxx yyy
做代理转发,则在tinyproxy.conf最后加上一行
upstream http user:pass@host:port
4,参考资料:
Tinyproxy安装与配置(ip代理) - 林先生
http://httpbin.org/get?show_env=1
TinyProxy 使用帮助 - 简书
https://github.com/tinyproxy/tinyproxy
================================
版本二
1.安装TinyProxy
yum install -y epel-release
yum update -y ——升级yum,可能会等很长一段时间
yum install -y tinyproxy
2.配置TinyProxy
(1)vi /etc/tinyproxy/tinyproxy.conf修改两处配置:端口号和允许连接该代理的IP白名单:
默认用8888端口作为代理端口,可以修改为你用作代理端口的端口号;
允许访问该代理端口的IP,默认为只有本机可以使用该代理,把这行注释掉可以使所有IP都可以使用该代理。
(2)配置完后,重启TinyProxy
systemctl enable tinyproxy.service
systemctl restart tinyproxy.service
防火墙开放你的配置的代理端口:
iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
3.验证TinyProxy
在另一台主机上运行以下命令检查是否用了代理:
curl -x 代理服务器IP地址:代理端口 httpbin.org/get
访问httpbin.org/get得到本地IP为119.23.xx.x,通过代理端口访问该地址,得到的IP地址为114.104.xx.x,这说明代理搭建成功。
systemctl start tinyproxy #启动服务systemctl stop tinyporxy # 关闭服务systemctl restart tinyporxy # 重启服务systemctl enable tinyproxy # 添加到开机启动systemctl disable tinyproxy # 移除开机启动
OS:CentOS Linux release 7.6.1810 (Core)
tinyproxy 版本:Release 1.11.1 ps:1.10版本后支持设置用户密码,类似squid
2,安装步骤,配置文件,启动:
官网及下载地址:
https://github.com/tinyproxy/tinyproxy
https://github.com/tinyproxy/tinyproxy/releases/tag/1.11.1
https://github.com/tinyproxy/tinyproxy/releases/download/1.11.1/tinyproxy-1.11.1.tar.gz
wget https://github.com/tinyproxy/tinyproxy/releases/download/1.11.1/tinyproxy-1.11.1.tar.gz
解压,安装:
tar xvpf tinyproxy-1.11.1.tar.gz
cd tinyproxy-1.11.1
./autogen.sh
./configure
make
make install
执行后会产生可执行程序:/usr/local/bin/tinyproxy 配置文件:/usr/local/etc/tinyproxy/tinyproxy.conf
默认的配置文件可以不管,我们创建自定义的配置文件 tinyproxy.conf,只需要简单配置几个核心参数即可:
mkdir /etc/tinyproxy/
vi /etc/tinyproxy/tinyproxy.conf
# 用户和组
User nobody
Group nobody
# 监听端口
Port 8888
# 在多网卡的情况下,设置出口 IP 是否与入口 IP 相同。默认情况下是关闭的
BindSame yes
# 超时时间
Timeout 30
# 这个地方建议建立一个空文件给到报错时读取的文件模板,默认的模板会打印tinyproxy等信息,其他人可以通过输入错误认证信息得到tinyproxy代理服务名字,版本等。
DefaultErrorFile "/usr/local/share/tinyproxy/default_nooutput.html"
#DefaultErrorFile "/usr/local/share/tinyproxy/default.html"
#该选项配置被当作统计主机的主机名或者IP地址:每当收到对该主机的请求时,Tinyproxy 会返回内部统计信息页面,而不会将请求转发给该主机。此页面的模板可以使用 StatFile 配置项进行配置。StatHost 的默认值为 tinyproxy.stats。
StatHost "127.0.0.1"
StatFile "/usr/local/share/tinyproxy/stats.html"
# 指定日志位置
LogFile "/var/log/tinyproxy/tinyproxy.log"
LogLevel Info
# 设置最大客户端链接数
MaxClients 1024
#RFC 2616 要求代理将 Via 标头添加到 HTTP 请求中,但使用真实主机名可能会引起安全问题。 如果设置了 ViaProxyName 选项,其字符串值将用作 Via 标头中的主机名。 否则,将使用服务器的主机名。
ViaProxyName "baidu"
# 将此选项设置为Yes将通知Tinyproxy将包含客户端IP地址的标头X-Tinyproxy添加到请求中。
# 如果是yes 则在header头中会添加原始ip,非高匿名模式,默认是 no
# 如果是yes 代理提交出去的header中会包含:"X-Tinyproxy": "127.0.0.1"
XTinyproxy no
# 该选项设置为 yes 时,Tinyproxy 不会将 Via 标头添加到请求中。 这实际上就使 Tinyproxy 进入了隐身模式。请注意,RFC 2616 要求代理设置 Via 头,因此启用此选项会破坏合规性。 除非您知道自己在做什么,否则不要禁用 Via 标头...
# 默认是 no ,遵循了RFC 2616协议,代理需要带上头说明自己是代理服务过来的请求
# 如果是 no 代理提交出去的header中会包含:"Via": "1.1 xxxx (tinyproxy/1.11.1)"
DisableViaHeader yes
#以上两条修改后就能做到高匿名
# 权限校验
BasicAuth xxx yyy
设置启动脚本:
vi /usr/bin/tp
#!/bin/bash
if [ $# -lt 1 ]
then
echo "No Args Input..."
exit ;
fi
case $1 in
"start")
echo " =================== 启动 ==================="
nohup tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf > /dev/null 2>&1 &
;;
"stop")
echo " =================== 关闭 ==================="
ps -ef|grep tinyproxy|grep -v grep|awk '{print "kill -9 "$2}'|sh
;;
"restart")
echo " =================== 重启 ==================="
ps -ef|grep tinyproxy|grep -v grep|awk '{print "kill -9 "$2}'|sh
nohup tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf > /dev/null 2>&1 &
;;
"status")
echo " =================== 状态 ==================="
ps -ef|grep tinyproxy|grep -v grep
;;
*)
echo "Input Args Error..."
;;
esac
设置权限:
chmod 777 /usr/bin/tp
启动控制:
tp start
tp stop
tp status
tp restart
查看日志:
tail -f /var/log/tinyproxy/tinyproxy.log
3,正式测试:
在另一台公网ip机器上用curl测试,成功没有显示任何代理信息,真正做到了http协议的 高匿名+账号密码验证 代理服务:
curl -x http://xxx:yyy@xxx.xxx.xxx.xxx:8888 http://httpbin.org/get?show_env=1
{
"args": {
"show_env": "1"
},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/7.29.0",
"X-Amzn-Trace-Id": "Root=2-6361231232a-2a123d67c1231231231644946e55a",
"X-Forwarded-For": "xxx.xxx.xxx.xxx",
"X-Forwarded-Port": "80",
"X-Forwarded-Proto": "http"
},
"origin": "xxx.xxx.xxx.xxx",
"url": "http://httpbin.org/get?show_env=1"
}
设置无需认证的代理,则把 tinyproxy.conf的最后一行注释即可。
BasicAuth xxx yyy
做代理转发,则在tinyproxy.conf最后加上一行
upstream http user:pass@host:port
4,参考资料:
Tinyproxy安装与配置(ip代理) - 林先生
http://httpbin.org/get?show_env=1
TinyProxy 使用帮助 - 简书
https://github.com/tinyproxy/tinyproxy
================================
版本二
1.安装TinyProxy
yum install -y epel-release
yum update -y ——升级yum,可能会等很长一段时间
yum install -y tinyproxy
2.配置TinyProxy
(1)vi /etc/tinyproxy/tinyproxy.conf修改两处配置:端口号和允许连接该代理的IP白名单:
默认用8888端口作为代理端口,可以修改为你用作代理端口的端口号;
允许访问该代理端口的IP,默认为只有本机可以使用该代理,把这行注释掉可以使所有IP都可以使用该代理。
(2)配置完后,重启TinyProxy
systemctl enable tinyproxy.service
systemctl restart tinyproxy.service
防火墙开放你的配置的代理端口:
iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
3.验证TinyProxy
在另一台主机上运行以下命令检查是否用了代理:
curl -x 代理服务器IP地址:代理端口 httpbin.org/get
访问httpbin.org/get得到本地IP为119.23.xx.x,通过代理端口访问该地址,得到的IP地址为114.104.xx.x,这说明代理搭建成功。
systemctl start tinyproxy #启动服务systemctl stop tinyporxy # 关闭服务systemctl restart tinyporxy # 重启服务systemctl enable tinyproxy # 添加到开机启动systemctl disable tinyproxy # 移除开机启动
一、问题描述:
报错概述:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
## 警告:pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。
二、解决方案:
首先要明白python版本需要和openssl的版本需要相对匹配的,在Python3.7之后的版本,依赖的openssl,必须要是1.1或者1.0.2之后的版本,或者安装了2.6.4之后的libressl,linux自带的openssl版本过低。
1、查看liunx系统的openssl版本信息:
openssl version
如图所示:小编的买的liunx服务器自带的openssl版本为1.1.1a ,然而对于小编来说,要安装python3.10的版本来说,openssl的版本太低了,因此需要更新openssl的版本才能满足要求;
先卸载之前安装的旧版本
yum -y remove openssl openssl-devel
2、更新openssl版本:
(1)安装相关依赖
yum install gcc libffi-devel zlib* openssl-devel
yum -y install perl-IPC-Cmd
安装perl-CPAN
[root@centos7 ~]# yum install -y perl-CPAN
进入CPAN的shell模式,首次进入需要配置shell,按照提示操作即可(本人perl小白,全部选择默认配置,高手请根据提示自行选择)
[root@centos7 ~]# perl -MCPAN -e shell
在shell中安装缺少的模块
cpan[1]> install IPC/Cmd.pm
安装成功后,重新编译OpenSSL即可
(2)官网下载openssl版本
wget https://www.openssl.org/source/openssl-3.0.1.tar.gz
(3)解压openssl
tar -zxvf openssl-3.0.1.tar.gz
(4)编译openssl
# 进入解压后的文件目录,切记一定要进入该目录才能继续执行后续命令
cd openssl-3.0.1
其中--prefix是指定安装目录的,shared zlib库是在安装时寻找zlib库依赖的
# 配置(configure)
./config --prefix=/usr/local/openssl
# 编译
make
# 安装
make install
最后重新查看openssl版本
openssl version
#建立新的软链接
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
#更新动态链接库
echo "/usr/local/openssl/lib64" >> /etc/ld.so.conf
ldconfig -v
ldd /usr/local/openssl/bin/openssl
==========================
2、重新编译python
安装依赖
yum -y update
yum -y install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel
(1)官网下载python
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
(2)解压python
tar -xzvf Python-3.10.5.tgz
(3)编译 python
./configure --with-ssl --prefix=/usr/local/python3/
make && make install
4)建立软连接
sudo ln -sf /usr/local/python3/bin/python3.10 /usr/bin/python
sudo ln -sf /usr/local/python3/bin/python3.10 /usr/bin/python3
sudo ln -sf /usr/local/python3/bin/pip3.10 /usr/bin/pip
sudo ln -sf /usr/local/python3/bin/pip3.10 /usr/bin/pip3
报错概述:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
## 警告:pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。
二、解决方案:
首先要明白python版本需要和openssl的版本需要相对匹配的,在Python3.7之后的版本,依赖的openssl,必须要是1.1或者1.0.2之后的版本,或者安装了2.6.4之后的libressl,linux自带的openssl版本过低。
1、查看liunx系统的openssl版本信息:
openssl version
如图所示:小编的买的liunx服务器自带的openssl版本为1.1.1a ,然而对于小编来说,要安装python3.10的版本来说,openssl的版本太低了,因此需要更新openssl的版本才能满足要求;
先卸载之前安装的旧版本
yum -y remove openssl openssl-devel
2、更新openssl版本:
(1)安装相关依赖
yum install gcc libffi-devel zlib* openssl-devel
yum -y install perl-IPC-Cmd
安装perl-CPAN
[root@centos7 ~]# yum install -y perl-CPAN
进入CPAN的shell模式,首次进入需要配置shell,按照提示操作即可(本人perl小白,全部选择默认配置,高手请根据提示自行选择)
[root@centos7 ~]# perl -MCPAN -e shell
在shell中安装缺少的模块
cpan[1]> install IPC/Cmd.pm
安装成功后,重新编译OpenSSL即可
(2)官网下载openssl版本
wget https://www.openssl.org/source/openssl-3.0.1.tar.gz
(3)解压openssl
tar -zxvf openssl-3.0.1.tar.gz
(4)编译openssl
# 进入解压后的文件目录,切记一定要进入该目录才能继续执行后续命令
cd openssl-3.0.1
其中--prefix是指定安装目录的,shared zlib库是在安装时寻找zlib库依赖的
# 配置(configure)
./config --prefix=/usr/local/openssl
# 编译
make
# 安装
make install
最后重新查看openssl版本
openssl version
#建立新的软链接
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
#更新动态链接库
echo "/usr/local/openssl/lib64" >> /etc/ld.so.conf
ldconfig -v
ldd /usr/local/openssl/bin/openssl
==========================
2、重新编译python
安装依赖
yum -y update
yum -y install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel
(1)官网下载python
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
(2)解压python
tar -xzvf Python-3.10.5.tgz
(3)编译 python
./configure --with-ssl --prefix=/usr/local/python3/
make && make install
4)建立软连接
sudo ln -sf /usr/local/python3/bin/python3.10 /usr/bin/python
sudo ln -sf /usr/local/python3/bin/python3.10 /usr/bin/python3
sudo ln -sf /usr/local/python3/bin/pip3.10 /usr/bin/pip
sudo ln -sf /usr/local/python3/bin/pip3.10 /usr/bin/pip3
查看防火墙是否开启
systemctl start friewall.service
//开启防火墙
firewall-cmd --state
//查询防火墙运行状态
firewall-cmd --list-all
添加防火墙规则
放行单个端口
firewall-cmd --permanent --add-port=80/tcp
//开放80端口,允许外面访问
放行某一段端口号
firewall-cmd --permanent --zone=public --add-port=1000-2000/tcp
firewall-cmd --reload
放行某个ip进行访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.169 accept'
firewall-cmd --reload
放行某段IP进行访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.0/24 accept'
禁止某个ip进行访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.42 drop'
firewall-cmd --reload
放行某个ip访问某个端口
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.169 port protocol=tcp port=6379 accept'
firewall-cmd --reload
移除防火墙规则
移除一条规则
firewall-cmd --permanent --remove-port=80/tcp
firewall-cmd --reload
移除以上规则
firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="192.168.1.169" port port="6379" protocol="tcp" accept'
firewall-cmd --reload
systemctl start friewall.service
//开启防火墙
firewall-cmd --state
//查询防火墙运行状态
firewall-cmd --list-all
添加防火墙规则
放行单个端口
firewall-cmd --permanent --add-port=80/tcp
//开放80端口,允许外面访问
放行某一段端口号
firewall-cmd --permanent --zone=public --add-port=1000-2000/tcp
firewall-cmd --reload
放行某个ip进行访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.169 accept'
firewall-cmd --reload
放行某段IP进行访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.0/24 accept'
禁止某个ip进行访问
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.42 drop'
firewall-cmd --reload
放行某个ip访问某个端口
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.169 port protocol=tcp port=6379 accept'
firewall-cmd --reload
移除防火墙规则
移除一条规则
firewall-cmd --permanent --remove-port=80/tcp
firewall-cmd --reload
移除以上规则
firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="192.168.1.169" port port="6379" protocol="tcp" accept'
firewall-cmd --reload
购买一个腾讯轻量云或者阿里轻量云。推荐选择香港。系统镜像必须centos7.6 千万别选错,别的不用修改 都选默认,买一个月24块钱的.
打开购买的轻量云
阿里先把防火墙端口添加全部tcp+udp协议端口
腾讯防火墙添加的是全部all端口
然后运行云服务器(远程连接服务器)
输入:
按下回车
输入:
按下回车
输入:
按下回车
5.等他安装完
出现绿字就ok了
6.sk5就是43.133.172.82|8888|123123|123123
7.安装完yo找个代理软件测试下
打开购买的轻量云
阿里先把防火墙端口添加全部tcp+udp协议端口
腾讯防火墙添加的是全部all端口
然后运行云服务器(远程连接服务器)
输入:
sudo su root
按下回车
输入:
wget --no-check-certificate https://raw.github.com/Lozy/danted/master/install.sh -O install.sh
按下回车
输入:
bash install.sh --port=8888 --user=123123 --passwd=123123
按下回车
5.等他安装完
出现绿字就ok了
6.sk5就是43.133.172.82|8888|123123|123123
7.安装完yo找个代理软件测试下
chatGPT代理服务器搭建
yum -y install wget
wget http://soft.vpser.net/lnmp/lnmp1.9-full.tar.gz
tar -zxvf lnmp1.9-full.tar.gz
cd lnmp1.9-full
./install.sh nginx
生成证书
cd /usr/local
mkdir secret
cd secret
openssl genrsa -out private.key 2048
openssl req -new -key private.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey private.key -out server.crt
修改nginx.conf内容为
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 443 ssl ; #监听端口号
server_name api.abc.com; #域名或服务器ip
proxy_read_timeout 240s; #设置超时时间
ssl_certificate /usr/local/secret/server.crt; #对应前面生成密钥的位置
ssl_certificate_key /usr/local/secret/private.key; #对应前面生成密钥的位置
#charset koi8-r;
#access_log logs/host.access.log main;
location /v1/ {
proxy_pass https://api.openai.com; # 反向代理到https://api.openai.com/这个地址
proxy_set_header Host api.openai.com; # 设置代理请求头中的Host字段为api.openai.com
proxy_ssl_server_name on; # 开启代理SSL服务器名称验证,确保SSL连接的安全性
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
chatGPT的接口地址换成:https://api.abc.com/v1/chat/completions 即可
yum -y install wget
wget http://soft.vpser.net/lnmp/lnmp1.9-full.tar.gz
tar -zxvf lnmp1.9-full.tar.gz
cd lnmp1.9-full
./install.sh nginx
生成证书
cd /usr/local
mkdir secret
cd secret
openssl genrsa -out private.key 2048
openssl req -new -key private.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey private.key -out server.crt
修改nginx.conf内容为
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 443 ssl ; #监听端口号
server_name api.abc.com; #域名或服务器ip
proxy_read_timeout 240s; #设置超时时间
ssl_certificate /usr/local/secret/server.crt; #对应前面生成密钥的位置
ssl_certificate_key /usr/local/secret/private.key; #对应前面生成密钥的位置
#charset koi8-r;
#access_log logs/host.access.log main;
location /v1/ {
proxy_pass https://api.openai.com; # 反向代理到https://api.openai.com/这个地址
proxy_set_header Host api.openai.com; # 设置代理请求头中的Host字段为api.openai.com
proxy_ssl_server_name on; # 开启代理SSL服务器名称验证,确保SSL连接的安全性
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
chatGPT的接口地址换成:https://api.abc.com/v1/chat/completions 即可
error_reporting(E_ALL);
//禁止把错误输出到页面
ini_set('display_errors', 0);
//设置错误信息输出到文件
ini_set('log_errors', 1);
//指定错误日志文件名
$error_dir = AMY_ROOT.'/data/log/';
$error_file = $error_dir . date('Ymd').'.log';
//目录不存在就创建
if (!is_dir($error_dir)){
mkdir($error_dir, 0777, true);
}
//文件不存在就创建之
if(!file_exists($error_file)){
$fp = fopen($error_file, 'w+');
if($fp){
fclose($fp);
}
}
//设置错误输出文件
ini_set("error_log", $error_file);
//程序正常执行逻辑......
daddslashes amy_addslashes
dstripslashes amy_stripslashes
dhtmlspecialchars amy_htmlspecialchars
dsafe amy_safe
dstripslashes amy_stripslashes
dhtmlspecialchars amy_htmlspecialchars
dsafe amy_safe
1、下载所需的安装包:
先把两个包放在/usr/src/下。
a、rsync下载路径:http://rsync.samba.org/ftp/rsync/src/rsync-3.0.9.tar.gz
b、inotify下载路径:http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
源服务器:192.168.0.1 目录 /opt/test/
目标服务器:192.168.0.2 目录 /opt/test/
实现的目的就是保持这两个服务器某个文件目录保持实时同步
2. rsync 同步软件
在 源服务器 和 目标服务器 都需要安装
源服务器: 是rsync客户端,不需要配置
目标服务器: 是rsync服务器端,需要配置/etc/rsyncd.conf里的内容
3.安装rsync:
[root@nginx ~]# cd /usr/src/
[root@nginx src]# tar zxvf rsync-3.0.9.tar.gz
[root@nginx src]# cd rsync-3.0.9
[root@nginx rsync-3.0.9]# ./configure --prefix=/usr/local/rsync
[root@nginx rsync-3.0.9]# make
[root@nginx rsync-3.0.9]# make install
创建密码认证文件:
[root@nginx rsync-3.0.9]# cd /usr/local/rsync/
[root@nginx rsync]# echo "Ad3rh5u3f" >/usr/local/rsync/rsync.passwd
给密码文件赋予600权限:
[root@nginx rsync]# chmod 600 rsync.passwd
安装后需要新建配置文件:/etc/rsyncd.conf
文件内容如下:
uid = root
gid = root
use chroot = no
max connections = 10
strict modes = yes
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
log file= =/var/run/rsyncd.log
[www]
path= /opt/test
comment= web file
ignore errors
read only = no
write only = no
hosts allow = 192.168.0.1
hosts deny = *
list = false
uid = root
gid = root
auth users = webuser
secrets file = /usr/local/rsync/rsync.passwd
3.安装inotify
该工具为文件实时监控工具
注意: 在 源服务器上需要安装,目标服务器上不需要安装inotify。
[root@nginx rsync]# cd /usr/src/
[root@nginx src]# tar zxvf inotify-tools-3.14.tar.gz
[root@nginx src]# cd inotify-tools-3.14
[root@nginx inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify
[root@nginx inotify-tools-3.14]# make
[root@nginx inotify-tools-3.14]# make install
4.创建监控脚本
#!/bin/bash
host=192.168.0.2
src=/opt/test/
des=www
user=webuser
/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src \
| while read files
do
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/usr/local/rsync/rsync1.passwd $src $user@$host::$des
echo "${files} was rsynced" >>/tmp/rsync.log 2>&1
done
注意: 这里的 www 是在目标服务器/etc/rsyncd.conf里配置的模块名称:[www]
赋予执行权限:
然后执行:
5. 关于启动
目标服务器:先启动rsync后台服务: /usr/bin/rsync --daemon
来源服务器: 执行sh inotify_bak.sh &
6. 测试:
在来源服务器目录中新建目录和文件,inotify_bak.sh脚本会检测到,然后同步到目标服务器的相关目录下
可以查看日志文件: /opt/soft/log/rsync.log 命令如下:观察实时同步的情况。
tail -f /tmp/rsync.log
先把两个包放在/usr/src/下。
a、rsync下载路径:http://rsync.samba.org/ftp/rsync/src/rsync-3.0.9.tar.gz
b、inotify下载路径:http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
源服务器:192.168.0.1 目录 /opt/test/
目标服务器:192.168.0.2 目录 /opt/test/
实现的目的就是保持这两个服务器某个文件目录保持实时同步
2. rsync 同步软件
在 源服务器 和 目标服务器 都需要安装
源服务器: 是rsync客户端,不需要配置
目标服务器: 是rsync服务器端,需要配置/etc/rsyncd.conf里的内容
3.安装rsync:
[root@nginx ~]# cd /usr/src/
[root@nginx src]# tar zxvf rsync-3.0.9.tar.gz
[root@nginx src]# cd rsync-3.0.9
[root@nginx rsync-3.0.9]# ./configure --prefix=/usr/local/rsync
[root@nginx rsync-3.0.9]# make
[root@nginx rsync-3.0.9]# make install
创建密码认证文件:
[root@nginx rsync-3.0.9]# cd /usr/local/rsync/
[root@nginx rsync]# echo "Ad3rh5u3f" >/usr/local/rsync/rsync.passwd
给密码文件赋予600权限:
[root@nginx rsync]# chmod 600 rsync.passwd
安装后需要新建配置文件:/etc/rsyncd.conf
文件内容如下:
uid = root
gid = root
use chroot = no
max connections = 10
strict modes = yes
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
log file= =/var/run/rsyncd.log
[www]
path= /opt/test
comment= web file
ignore errors
read only = no
write only = no
hosts allow = 192.168.0.1
hosts deny = *
list = false
uid = root
gid = root
auth users = webuser
secrets file = /usr/local/rsync/rsync.passwd
3.安装inotify
该工具为文件实时监控工具
注意: 在 源服务器上需要安装,目标服务器上不需要安装inotify。
[root@nginx rsync]# cd /usr/src/
[root@nginx src]# tar zxvf inotify-tools-3.14.tar.gz
[root@nginx src]# cd inotify-tools-3.14
[root@nginx inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify
[root@nginx inotify-tools-3.14]# make
[root@nginx inotify-tools-3.14]# make install
4.创建监控脚本
#!/bin/bash
host=192.168.0.2
src=/opt/test/
des=www
user=webuser
/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src \
| while read files
do
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/usr/local/rsync/rsync1.passwd $src $user@$host::$des
echo "${files} was rsynced" >>/tmp/rsync.log 2>&1
done
注意: 这里的 www 是在目标服务器/etc/rsyncd.conf里配置的模块名称:[www]
赋予执行权限:
chmod +x inotify_bak.sh
然后执行:
sh inotify_bak.sh &
放入后台执行5. 关于启动
目标服务器:先启动rsync后台服务: /usr/bin/rsync --daemon
来源服务器: 执行sh inotify_bak.sh &
6. 测试:
在来源服务器目录中新建目录和文件,inotify_bak.sh脚本会检测到,然后同步到目标服务器的相关目录下
可以查看日志文件: /opt/soft/log/rsync.log 命令如下:观察实时同步的情况。
tail -f /tmp/rsync.log
通过命令: nmap -sV --script ssl-enum-ciphers -p 443 www.example.com 可得:
Starting Nmap 6.40 ( http://nmap.org ) at 2021-10-08 14:51 CST
Nmap scan report for 127.0.0.1
Host is up (0.035s latency).
PORT STATE SERVICE VERSION
443/tcp open http nginx 1.19.10
| ssl-enum-ciphers:
| TLSv1.2:
| ciphers:
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA - strong
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 - strong
| TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - strong
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA - strong
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 - strong
| TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - strong
| TLS_ECDHE_RSA_WITH_RC4_128_SHA - strong
| TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA - broken
| TLS_ECDH_anon_WITH_AES_128_CBC_SHA - broken
| TLS_ECDH_anon_WITH_AES_256_CBC_SHA - broken
| TLS_ECDH_anon_WITH_RC4_128_SHA - broken
| TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 - weak
| TLS_RSA_EXPORT_WITH_RC4_40_MD5 - weak
| TLS_RSA_WITH_3DES_EDE_CBC_SHA - strong
| TLS_RSA_WITH_AES_128_CBC_SHA - strong
| TLS_RSA_WITH_AES_256_CBC_SHA - strong
| TLS_RSA_WITH_AES_256_CBC_SHA256 - strong
| TLS_RSA_WITH_AES_256_GCM_SHA384 - strong
| TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - strong
| compressors:
| NULL
|_ least strength: strong
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.09 seconds
结果中weak(柔弱的)、broken(损坏的)、strong(坚固的)字段表示加密强度,为了安全需要将128位以下弱加密算法禁用,Nginx 配置 SSL需明确指定算法:
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!3DES:!ADH:!RC4:!DH:!DHE;
重启是nginx.conf配置生效
nginx -s reload
Starting Nmap 6.40 ( http://nmap.org ) at 2021-10-08 14:51 CST
Nmap scan report for 127.0.0.1
Host is up (0.035s latency).
PORT STATE SERVICE VERSION
443/tcp open http nginx 1.19.10
| ssl-enum-ciphers:
| TLSv1.2:
| ciphers:
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA - strong
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 - strong
| TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - strong
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA - strong
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 - strong
| TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - strong
| TLS_ECDHE_RSA_WITH_RC4_128_SHA - strong
| TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA - broken
| TLS_ECDH_anon_WITH_AES_128_CBC_SHA - broken
| TLS_ECDH_anon_WITH_AES_256_CBC_SHA - broken
| TLS_ECDH_anon_WITH_RC4_128_SHA - broken
| TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 - weak
| TLS_RSA_EXPORT_WITH_RC4_40_MD5 - weak
| TLS_RSA_WITH_3DES_EDE_CBC_SHA - strong
| TLS_RSA_WITH_AES_128_CBC_SHA - strong
| TLS_RSA_WITH_AES_256_CBC_SHA - strong
| TLS_RSA_WITH_AES_256_CBC_SHA256 - strong
| TLS_RSA_WITH_AES_256_GCM_SHA384 - strong
| TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - strong
| compressors:
| NULL
|_ least strength: strong
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.09 seconds
结果中weak(柔弱的)、broken(损坏的)、strong(坚固的)字段表示加密强度,为了安全需要将128位以下弱加密算法禁用,Nginx 配置 SSL需明确指定算法:
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!3DES:!ADH:!RC4:!DH:!DHE;
重启是nginx.conf配置生效
nginx -s reload