linux 搭建TinyProxy代理服務器---安裝和測試

一、簡單概述

  1. TinyProxy介紹
    TinyProxy是輕量級的開源 HTTP/HTTPS 代理守護程序(輕量級http代理服務器),它從一開始就設計得既快又小,是一個理想的解決方案,適用於需要全功能HTTP代理的嵌入式部署等用例,但無法使用較大代理的系統資源。
  2. 特性
    ·體積小
    ·佔用少量的系統資源
    ·兼容性不錯

二、安裝

  1. 下載tinyproxy軟件
    如需要,請點擊tinyproxy-1.6.3.tar下載!!!密碼:sfyq
  2. 上傳linux服務器並解壓到指定目錄
[gis@leilei source-package]$ tar -xvf tinyproxy-1.6.3.tar
  1. tinyproxy啓動文件的位置
[gis@leilei ~]$ sudo su
[root@leilei gis]# cd  /usr/bin/tinyproxy-1.6.3/sbin
[root@leilei sbin]# ll
total 92
-rwxr-x--- 1 gis gis 91200 Apr 27 18:34 tinyproxy
  1. tinyproxy.conf配置文件所放置的位置
[root@leilei sbin]# cd /etc
[root@leilei etc]# vi tinyproxy.conf
##
## tinyproxy.conf -- tinyproxy daemon configuration file
# User nobody
# Group nogroup
User root
Group root
#
# Port to listen on.
#
Port 8100

#
# If you have multiple interfaces this allows you to bind to only one. If
# this is commented out, tinyproxy will bind to all interfaces present.
#
#Listen 192.168.0.1

#
# The Bind directive allows you to bind the outgoing connections to a
# particular IP address.
#
#Bind 192.168.0.1

#
# Timeout: The number of seconds of inactivity a connection is allowed to
# have before it closed by tinyproxy.
#
Timeout 600
#
# DefaultErrorFile: The HTML file that gets sent if there is no
# HTML file defined with an ErrorFile keyword for the HTTP error
DefaultErrorFile "/usr/share/tinyproxy/default.html"

#
# StatFile: The HTML file that gets sent when a request is made
# for the stathost.  If this file doesn't exist a basic page is
# hardcoded in tinyproxy.
#
StatFile "/usr/share/tinyproxy/stats.html"

#
# Where to log the information. Either LogFile or Syslog should be set,
# but not both.
#
Logfile "/var/log/tinyproxy.log"
# Syslog On

#
# Set the logging level. Allowed settings are:
#       Critical        (least verbose)
#       Error
#       Warning
#       Notice
#       Connect         (to log connections without Info's noise)
#       Info            (most verbose)
# The LogLevel logs from the set level and above. For example, if the LogLevel
# was set to Warning, than all log messages from Warning to Critical would be
# output, but Notice and below would be suppressed.
#
LogLevel Info

#
# PidFile: Write the PID of the main tinyproxy thread to this file so it
# can be used for signalling purposes.
#
PidFile "/var/run/tinyproxy.pid"


#
# This is the absolute highest number of threads which will be created. In
# other words, only MaxClients number of clients can be connected at the
# same time.
#
MaxClients 100

#
# These settings set the upper and lower limit for the number of
# spare servers which should be available. If the number of spare servers
# falls below MinSpareServers then new ones will be created. If the number
# of servers exceeds MaxSpareServers then the extras will be killed off.
#
MinSpareServers 5
MaxSpareServers 20

#
# Number of servers to start initially.
#
StartServers 10

#
# MaxRequestsPerChild is the number of connections a thread will handle
# before it is killed. In practise this should be set to 0, which disables
# thread reaping. If you do notice problems with memory leakage, then set
# this to something like 10000
#
MaxRequestsPerChild 0
#
# The following is the authorization controls. If there are any access
# control keywords then the default action is to DENY. Otherwise, the
# default action is ALLOW.
#
# Also the order of the controls are important. The incoming connections
# are tested against the controls based on order.
#
# Allow 127.0.0.1
# Allow 192.168.1.0/25

#
# The "Via" header is required by the HTTP RFC, but using the real host name
# is a security concern.  If the following directive is enabled, the string
# supplied will be used as the host name in the Via header; otherwise, the
# server's host name will be used.
#
ViaProxyName "tinyproxy"
#
# This is a list of ports allowed by tinyproxy when the CONNECT method
# is used.  To disable the CONNECT method altogether, set the value to 0.
# If no ConnectPort line is found, all ports are allowed (which is not
# very secure.)
#
# The following two ports are used by SSL.
#
ConnectPort 443
ConnectPort 563
  1. 編寫啓動腳本
[root@leilei etc]# cd /gis/source-package/
[root@leilei source-package]# vi start_tinyproxy.sh 
# /bin/sh
cd /usr/bin/tinyproxy-1.6.3/sbin
sudo ./tinyproxy -c /etc/tinyproxy.conf
  1. 啓動start_tinyproxy.sh

三、測試

  1. 查看服務及監聽端口,看是否有tinyproxy程序端口和服務
[root@leilei source-package]# ./start_tinyproxy.sh 
[root@leilei source-package]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name        
tcp        0      0 0.0.0.0:8100            0.0.0.0:*               LISTEN      55347/./tinyproxy   
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      19186/nginx: master 
  1. 遠程主機使用postman軟件進行proxy代理配置和接口訪問測試
    打開postman->File->Settings->proxy
    在這裏插入圖片描述
    在這裏插入圖片描述
    接口進行測試,返回正確結果,宣告Linux tinyproxy代理安裝成功~在這裏插入圖片描述
    四、總結
    以上就是我在工作當中完成linux服務器tinyprox代理環境的搭建步驟,希望對有需要的朋友有一些幫助。請大家多多關注我後序博客的更新~
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章