centos部署http代理+解决国内服务器TGbot
使用
tgbot需要代理才能使用,参考各路大神,把适合自己的方法总结如下,本人小白,大佬勿喷:
首先,先把带密码的http代理的使用方法写上
http://账号:密码@ip:port
部署
安装openssl
判断是否安装openssl
openssl version -a
安装命令
yum install openssl
安装squid
yum install squid -y
# -y 代表自动选择y,全自动安装
安装net-tools
yum install net-tools
修改squid.conf
vi /etc/squid/squid.conf
找到http-port 默认3128 建议修改
然后增加一行logformat配置,加在最后一行
#此行加在配置文件末尾即可
#access log time human-readable
logformat squid %tl.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %un %Sh/%<A %mt
开启squid的端口,然后重新启动
firewall-cmd --zone=public --add-port=9128/tcp --permanent
firewall-cmd –reload
我这里设置的是9128,按照上一步自己的设置来改
如果报错,以下解决方法
启用防火墙
systemctl enable firewalld
动防火墙
systemctl start firewalld
查防火墙的状态
systemctl status firewalld
启动squid
systemctl start squid
尝试本机代理访问
curl -x 127.0.0.1:6128 www.baidu.com
说多了我也累,放个squid的配置代码,感谢巨佬:奋斗吧-皮卡丘
#
# Recommended minimum configuration:
## Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machinesacl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT#在配置文件的acl代码块下添加
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 2 hours
acl auth_users proxy_auth REQUIRED
http_access allow auth_users#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
## Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost#acl client src 0.0.0.0/0
#http_access allow client
http_access allow all
# And finally deny all other access to this proxy
#http_access deny all# Squid normally listens to port 3128
http_port 9999# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320request_header_access X-Forwarded-For deny all
request_header_access From deny all
request_header_access Via deny all#此行加在配置文件末尾即可
#access log time human-readable
logformat squid %tl.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %un %Sh/%<A %mt
直接把以前的所有替换掉,记得改自己已经打开防火墙的端口
然后重启squid
systemctl restart squid
设置用户密码
yum -y install httpd-tools
touch /etc/squid/passwd && chown squid /etc/squid/passwd
创建用户名
#创建用户密码
htpasswd /etc/squid/passwd yourusername
yourusername改成你的用户名就行
会让你输入两次密码,然后就完成了
再重启一次squid
设置开机自启
chkconfig --level 35 squid on
注意
一定要记得开启防火墙,有bt的bt也要开,用云服务器的安全组要打开!
centos部署http代理+解决国内服务器TGbot相关推荐
- vue反向代理解决跨域及部署nginx端口转发解决跨域
1. 前言 本文是为了解决vue反向代理解决跨域及部署服务器nginx端口转发解决跨域,因为踩了不少的坑,百度了很多,也试了太多的方法,最终得以解决,所以记录一下,希望遇到同样问题的友友们可以高效的解 ...
- 将Vue项目部署在Nginx,解决前端路由、反向代理和静态资源问题
将Vue项目部署在Nginx,解决前端路由.反向代理和静态资源问题 需求: 一台服务器,Linux 安装了Nginx 使用Vue脚手架编写的Vue项目 第一步:将Vue项目打包,然后将生成的dist文 ...
- 阿里云服务器CentOS部署Minio服务实现远程访问
阿里云服务器CentOS部署Minio服务实现远程访问 1.下载 1.1 建立文件夹 mkdir /usr/local/minio mkdir /usr/local/minio/data 1.2下载 ...
- 重定向解决国外服务器与国内域名备案的问题
情景:有2个域名 .1个服务器,服务器在美国机房.然后我把域名都解析过去,国外的服务器嘛,不用备案.可是随着时间的推移,业务的增加,要用到七牛云的加速cdn,要有一个备案好的加速域名,微信分享到朋友或 ...
- android studio开发环境搭建,国内服务器代理下载android sdk
android studio开发环境搭建 1,百度android studio,下载安装: 2,启动Fetching Android SDK component information http:// ...
- hp服务器pe系统安装win7系统安装系统安装失败,使用硬盘安装系统出现pGptRestore部署失败怎么解决?...
使用硬盘安装系统出现pGptRestore部署失败怎么解决?最近有不少用户在安装系统的时候都出现了这种问题,那么当我们在安装系统的时候要怎么解决呢?下面小编就为大家讲解一下吧! 操作方法: 首先我们需 ...
- Vue代理解决生产环境跨域问题 部署必备干货
当我们前端要调用跨域接口时,我们需要用代理解决跨域问题,比如Vue的代理配置proxy,但是当Vue项目打包成静态文件时,他的代理也就失灵了,因为代理的前提是本地必须有service,本章讲一下生产环 ...
- 如何优雅的部署Python应用到Linux服务器?
文章目录 1 前言 2 安装Python3环境 2.1 安装所需的编译环境 2.2 下载Python源码包 2.3 解压 python-3.9.5 源码包 2.4 安装 python3 2.5 设置软 ...
- java搭建阿里云服务器环境(java环境+mysql+tomcat)和部署 JavaWeb 项目到云服务器
文章有不当之处,欢迎指正,如果喜欢微信阅读,你也可以关注我的微信公众号:好好学java,获取优质学习资源. 购买一系列的东西 其实就是花钱买块区域,服务器,域名,云解析,花了好多money... 一. ...
最新文章
- c语言笔试面试大全,C语言笔试面试题大全.doc
- 逻辑漏洞-找回密码修改返回包
- javascript 将内容复制到剪贴板
- python之从文件中按行读取数据
- ios高级开发之多线程(一)
- 封装出现 用户.计算机,ES4封装WIN7出现[Administrator.计算机名]目录的可能解决方案...
- mybatis循环map的一些技巧
- 空间自相关的知识总结
- android WebViewClient和WebChromeClient
- 使用Angularjs的ng-cloak指令避免页面乱码
- amd显卡bios更新工具_【硬件资讯】AMD又Yes啦?全新Ryzen 5000发布!游戏最强CPU尘埃落定!现有主板无缝衔接!!...
- 十大常用机器学习算法总结(持续完善)
- PMP课程笔记:第11章 项目风险管理
- 关于网页消息提示音问题解决与实现
- 用友NC单据模板公式
- tableau app android,tableau 安卓
- MPN (Learning Normal Dynamics in Videos with Meta Prototype Network)代码阅读
- 江苏省盐城中学信息竞赛队(YZOI)队规
- 【VUE+elementUI+JAVA】elementUI的<el-table>组件VUE自定义排序+后台排序含分页完整版
- 自考《管理经济学》之宏观理解