ATS反向代理环境搭建
apache2环境搭建
安装
sudo apt install apache2
端口配置,防止安装nginx端口冲突
ports.conf:5:Listen 8083
sites-available/000-default.conf:1:<VirtualHost *:8083>
nginx环境安装
安装
sudo apt install nginx
端口配置
listen 8094 default_server;
listen [::]:8094 default_server;
php文件解析配置
location ~ \.php$ {
include fastcgi_params;
# With php7.0-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
默认index文件配置,添加indexnginx.php
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html indexnginx.php;
本地HOST配置
172.31.19.188:8083 ats.mengsec.com
172.31.19.188:8094 lnmp.mengsec.com
ATS编译安装
下载
https://github.com/apache/trafficserver/archive/7.1.2.tar.gz
安装依赖&常用工具
apt-get install -y autoconf automake libtool pkg-config libmodule-install-perl gcc libssl-dev libpcre3-dev libcap-dev libhwloc-dev libncurses5-dev libcurl4-openssl-dev flex tcl-dev net-tools vim curl wget
解压源码,编译安装
autoreconf -if
./configure --prefix=/opt/ts-712
make
make install
如果需要关闭缓存功能
vim /opt/ts-712/etc/trafficserver/records.config
CONFIG proxy.config.http.cache.http INT 0 # 关闭缓存
CONFIG proxy.config.reverse_proxy.enabled INT 1 # 启用反向代理
CONFIG proxy.config.url_remap.remap_required INT 1 # 限制ats仅能访问map表中映射的地址
CONFIG proxy.config.http.server_ports STRING 80 80:ipv6 # 监听在本地80端口
编辑remap.config
配置文件,在末尾添加要映射的规则表。
vim /opt/ts-712/etc/trafficserver/remap.config
map http://lnmp.mengsec.com/ http://172.31.19.188:8094/
map http://ats.mengsec.com/ http://172.31.19.188:8083/
开启服务器
/home/osword/ts-712/bin
sudo ./trafficserver start
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!