Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1022822
  • 博文数量: 157
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1388
  • 用 户 组: 普通用户
  • 注册时间: 2015-04-09 15:37
文章分类

全部博文(157)

文章存档

2023年(9)

2022年(2)

2021年(18)

2020年(7)

2017年(13)

2016年(53)

2015年(55)

我的朋友

分类: 服务器与存储

2015-07-23 16:29:51

对于刚接触ats的人,不知道怎么入手,我刚开始学的时候也是这样,我想总结下搭建简单的ats环境的步骤,目的就是使用户请求可以通过ats进行缓存。

client----------->ats------------>源(nginx或apache)
机器a            机器b           机器c

1. 在b上安装ats安装包,此处省略具体的安装过程
2. 安装完成后需要修改下配置:
==record.config中:
CONFIG proxy.config.reverse_proxy.enabled INT 1        开启反向代理
CONFIG proxy.config.url_remap.remap_required  INT 1 开启remap功能
CONFIG proxy.config.http.cache.http INT 1                    开启http缓存功能
CONFIG proxy.config.log.custom_logs_enabled INT 1     设置为1可以看到访问日志access.log
【如果没有上边这个log的配置项可以将下面两项都配置成1,则可看到访问日志squid.log
CONFIG proxy.config.log.squid_log_enabled INT 1
CONFIG proxy.config.log.squid_log_is_ascii INT 1】
记住 CONFIG proxy.config.http.server_ports STRING 80    记住这个端口号,就是访问ats的端口

==remap.config中:
map
【map     return 403,原因我还没找出来】


3.验证ats是否安装成功并且通了
此时启动ats,看ats的三个进程是否都启动了,如果没有都启动,查看traffic.out或者traffic.diag查看下原因,是端口被占用了还是别的原因。有时候起不来是record.config中这个设置的原因:CONFIG proxy.config.admin.user_id STRING nobody 【需要把nobody改成#-1】,为什么这么改我还不是很清楚,需要大家一起探讨,应该是个权限问题,修改后log目录底下才出现diags.log和manager.log,详细解释间下面的备注。这时候访问wget -e http_proxy=ats机器的ip:port  -S   ,如果返回的是新浪页面的内容,则证明你的ats通了
,ats基本的配置就完成了。

备注:官网上对CONFIG proxy.config.admin.user_id配置项的解释:

proxy.config.admin.user_id
Scope: CONFIG
Type: STRING
Default: nobody

Option used to specify who to run the traffic_server process as; also used to specify ownership of config and log files.

The nonprivileged user account designated to Traffic Server.

As of version 2.1.1 if the user_id is prefixed with pound character (#) the remaining of the string is considered to be a . If the value is set to #-1 Traffic Server will not change the user during startup.

Setting user_id to root or #0 is now forbidden to increase security. Trying to do so, will cause thetraffic_server fatal failure. However there are two ways to bypass that restriction

  • Specify -DBIG_SECURITY_HOLE in CXXFLAGS during compilation.
  • Set the user_id=#-1 and start trafficserver as root.

=================================================
4. 引申:如果按照下面的方法自己配置了dns服务器和源,则可以通过设置完成访问自己定制域名的过程
修改record.config中配置:
CONFIG proxy.config.dns.nameservers STRING  x.x.x.x (此处为你自己配置的dns服务器的机器ip)
注意ats配置修改后需要重新加载配置
在nginx源的html目录下放上你想访问的内容,如test.jpg
此时访问:wget -e http_proxy=ats的ip:port ,如果展示了你放在nginx源上的那张图片,则证明成功了。
===================================

如上设置用的源是别人的,dns服务器是机器本身带的,在/etc/resolv.conf中,如8.8.8.8,解析 一般是可以解析出来的。如果想定制自己的域名,则需要有自己的dns服务器来解析这个域名;如果想自己定制源上的内容,则需要自己搭建源服务器,源服务器可以用nginx或apache。

==搭建dns服务器:
可参考:http://blog.chinaunix.net/uid-30199261-id-5131038.html

==搭建nginx源:
1. 安装nginx,此处省略具体安装过程,如安装在/usr/local/nginx下
2. 修改配置文件nginx.conf(下面为最基本的配置,nginx服务端口设置为8080):

worker_processes 1;
event{worker_connections 1024;}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
 server {
  listen 8080;
  server_name my.test.com;
  location / {
   root  /usr/local/nginx/html/;
   index  index.html index.htm;
         }
      }
}
3.验证nginx是否安装成功
启动nginx, /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf,服务端口为8080,如果查看nginx进程存在则nginx就安装成功了                    
【如果想让源对https请求进行相应支持,请参考
http://blog.chinaunix.net/uid-30199261-id-5116481.html

补充:还可自行设置缓存时间
ats上缓存时间的设置:
cache.config中:
dest_domain= scheme=http ttl-in-cache=1m 【ats中设置缓存时间为1min】


阅读(1493) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~