Archive for the 'Operating system' Category

Squid 2.7 通过域名反向代理多个服务器配置

visible_hostname squid1.abc.com

#设定squid的主机名,如无此项squid将无法启动

http_port 80 accel vhost vport

#设定squid为accel加速模式,vhost必须要加.否则将无法将主机头转发至后端服务器,访问时就会出现无法找到主机头的错误

cache_peer 192.168.1.88 parent 80 0 no-query originserver name=contentchina

cache_peer 192.168.1.88 parent 80 0 no-query originserver name=bbs

cache_peer 192.168.1.1 parent 80 0 no-query originserver name=ihompy

#定义不同的父节点,将节点设为no-query以及originserver说明这些节点是实际服务器

cache_peer_domain contentchina aaa.abc.com

cache_peer_domain bbs bbb.abc.com

cache_peer_domain ihompy ccc.abc.com

#设定不同域名转发到不同的cache_peer上,如果没有这项.不同域名的域名可能被分发到同一台服务器上.

acl all src 0.0.0.0/0.0.0.0

no_cache deny all

http_access allow all

#允许所有客户端访问

cache_log /var/log/squid/cache.log

#记录日志

#***********ACL存取控制*************

#acl QueryString url_regex .php?

#***********缓冲存取控制*************

#no_cache deny QueryString

#不对符合QueryString的ACL内容进行缓冲

#***********性能优化配置*************

maximum_object_size 320010 KB

#大于此容量的对象将不会被保存在磁盘上,默认大小是4M,如果squid服务器用于缓冲flash等大型文件,建议将此值变大.否则过大的文件在下次重启后将需要重新获取

maximum_object_size_in_memory 100 KB

#最大位于内存中的对象的大小,默认大小是8K,如果服务器内存很大.可以适当提高此值的大小,建议根据网站的80%图片的大小来定.或者根据WEB服务器实际存取文件中最常访问的文件大小来定制

#***********其他可选配置*************

#dns_nameservers 10.0.0.1 192.172.0.4

#配置DNS服务器地址.获取后端时将从此dns获取IP地址

#cache_mgr [email protected]

#在错误日志中出现的webmaster地址.

使用expect自动登录SSH脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/expect -f
set server [lindex $argv 0]

trap {
     set rows [stty rows]
      set cols [stty columns]
       stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH

switch -- $server \
    "mail" {
        spawn ssh -p 51 root@mail
        expect "password:"
        send "A)Q11dDuh^.\n"
        interact
    } "win1" {
        exec rdesktop -u administrator -p "aU\$B_C%K" 192.168.111.3
    } default {
        puts "input a server name"
    }

expect eof

Google chrome pac auto proxy file

don’t use only exts. Swithy will broken on chrome 12. so use pac file is a good way.

1
2
3
4
5
6
7
<pre>function FindProxyForURL(url, host)
{
    var regexpr = /(google|googleusercontent|gmodules|chromium|linkedin|filesonic|hotfile|fbcdn|wp|scanlover|android|pusherapp|jqueryui|wordpress|tornadoweb|angrybirds|28tube|goo|fc2|youtube|twitter|facebook|ytimg).com$/;
    if(regexpr.test(host))
        return "SOCKS5 127.0.0.1:7070; DIRECT";
    return "DIRECT";
}</pre>

start google chrome in command line google-chrome --proxy-pac-url=file:///home/fred/.proxy.pac

work on debian linux.

Nagios监控报警安装

一.Nagios简介

Nagios是一款遵循GPLv2的开源网络监控软件,可用来监控指定的多种系统的主机、服务,并可在它们的工作状态发生变化时通知管理员。

  1. 监控网络服务(HTTP、POP3、SMTP、PING、MySQL等)
  2. 监控主机资源(磁盘空间利用率、内存利用率、CPU负载等)
  3. 简洁的插件设计接口,使得用户可以轻松开发所需的检测脚本
  4. 并行服务模式
  5. 轻松描述网络结构,并且能够区辨“宕机”和“主机不可达”
  6. 通过邮件或用户自定义的方式将主机或服务的工作状态变化情况通知给管理员6)当服务或主机问题产生与解决时将告警发送给联系人(通过EMail、短信、用户定义方式) ?可以通过飞信,等方式实现时,既可传递给管理员,可高效的保证服务器的维护。
  7. 自动日志滚动
  8. 支持以冗余方式进行主机监控
  9. 可以通过web方式直观的查看当前网络状态、通知和问题历史、日志文件等等,此组件为可选
Continue reading ‘Nagios监控报警安装’

突破Windows XP SP3远程桌面连接数限制

长期在Linux下工作,但是常常需要在IE6下做WEB测试,于是在开发服务器上安装了Xen和Windows XP SP3。但是XP默认只能1个远程连接,所以需要“破解”。

  1. 下载破解过的termsrv.dll ,版本5.1.2600.5512,语言中文(中国)。
  2. 复制到windows\system32文件夹覆盖同名文件。(如果开着SFC还要覆盖dllcache或者servicepackfiles\i386里的)
  3. 运行RAR包里的MultipleTS.bat
  4. 运行gpedit.msc打开组策略,找到终端服务-限制连接数量改到2以上
  5. 确保启用快速用户切换和允许用户远程连接到此计算机
  6. 重启电脑确保更改生效

Nginx上ETag支持

1
2
3
4
5
6
    location ~* ^.+.(gif|jpg|css|js|png)$ {
        root   /var/web/static;
        FileETag on;
        etag_format \"%X%X\";
        add_header    Cache-Control     max-age=0;
    }

这样就可以返回304啦。

让Google Chrome模拟各种手机浏览器

  • 谷歌Android:
    1
    google-chrome --user-agent="Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
  • 苹果iPhone:
    1
    google-chrome --user-agent="Mozilla/5.0 (iPad; U; CPU OS 3_2_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B500 Safari/531.21.10"
  • 诺基亚N97:
    1
    google-chrome --user-agent="Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124"

更改Linux启动磁盘检测频率

1
sudo tune2fs -c 50 /dev/hda1

发现一个在Linux下煲耳机的好工具

http://wavb.sourceforge.net/

CACHE CONTROL WITH HTACCESS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Cache Control with .htaccess EXPIRES BY TYPE
# from http://forum.powweb.com/showthread.php?t=62786
 
### turn on the Expires engine
ExpiresActive On
 
### expires after a month in the client's cache
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType application/pdf A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/plain A2592000
 
### expires after 4.8 hours
ExpiresByType text/css A17200
 
# Please note that the "A" before the numbers above stands for Access.
# This means that the stopwatch starts when a client accesses the file.
# You can also use "M" for modified.
 
# TIME CHEAT SHEET
#      300   5 MIN
#      600  10 MIN
#      900  15 MIN
#     1800  30 MIN
#     2700  45 MIN
#
#     3600   1 HR
#     7200   2 HR
#    10800   3 HR
#    14400   4 HR
#    18000   5 HR
#    36000  10 HR
#    39600  11 HR
#    43200  12 HR
#    46800  13 HR
#    50400  14 HR
#    54000  15 HR
#    86400  24 HR
#
#    86400   1 DAY
#   172800   2 DAY
#   259200   3 DAY
#   345600   4 DAY
#   432000   5 DAY
#   518400   6 DAY
#   604800   7 DAY
#
#   604800   1 WEEK
#  1209600   2 WEEK
#  1814400   3 WEEK
#  2419200   4 WEEK
#
#  2419200   1 MONTH (FEBRUARY)
#  2505600   1 MONTH (FEBRUARY LEAP YEAR)
#  2592000   1 MONTH (APRIL, JUNE, SEPTEMBER, NOVEMBER)
#  2678400   1 MONTH (JANUARY, MARCH, MAY, JULY, AUGUST, OCTOBER, DECEMBER)
# 31536000  12 MONTH
1
2
3
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>