kangle配置文件php
(重定向自Kangle配置文件)html
目錄node
[隱藏] python
配置文件介紹linux
從新加載配置文件web
kangle -rapache
config編程
配置文件頂層標籤,其它指令都在config之下。windows
<?xml version="1.0" encoding="utf-8"?>後端
<config>
其它指令
</config>
request和response(配置訪問控制)
配置訪問控制,請參考kangle訪問控制
listen(端口配置)
配置靜態偵聽端口。 語法:
<listen
ip='*'
port='端口'
type='http|https|manage|manages'
certificate='證書文件地址'
certificate_key='key文件地址'
sni='1'
/>
例只偵聽ipv4的80端口
<listen ip='0.0.0.0' port='80' type='http' />
只偵聽ipv6的80端口
<listen ip='::' port='80' type='http' />
指定ip
<listen ip='127.0.0.1' port='80' type='http' />
偵聽ssl
<listen
ip='*'
port='443'
type='https'
certificate='證書文件地址'
certificate_key='key文件地址'
sni='1'
/>
run(unix系統設置kangle運行用戶)
unix系統設置kangle工做進程運行用戶。
<run user='用戶名' group='組名'/>
使如設置運行在kangle用戶下。
<run user='kangle' group='kangle'/>
lang(語言)
設置3311管理用的語言 使用中文
<lang>zh_CN</lang>
指明英語
<lang>en_US</lang>
keep_alive(http長鏈接)
設置http長鏈接超時時間,單位秒,設置爲0,則禁用http長鏈接(不建議).
<keep_alive>30</keep_alive>
connect_timeout(鏈接超時connect time out)
設置鏈接超時時間,單位秒
<connect_timeout>11</connect_timeout>
keep_alive_count(長鏈接過載保護)
長鏈接數默認是2000(能夠根據須要修改,如:200),新版加了這個參數,有效實現過載保護,鏈接數一超,就採用短鏈接。舊版沒有這個設置,鏈接數高,仍是保持長鏈接,致使負載過高。
<keep_alive_count>2000</keep_alive_count>
timeout(超時)
設置讀寫超時時間,單位秒,不能低於5秒,最好不超過120秒。
<timeout>30</timeout>
min_free_thread
設置回收空閒線程時,最小保留值。設置爲0,不保留。
<min_free_thread>0</min_free_thread>
gzip(gzip壓縮)
設置gzip壓縮
<gzip only_gzip_cache='0' min_gzip_length='256' gzip_level='5'/>
connect(鏈接數)
設置鏈接數
<connect max_per_ip='0' max='0' />
per_ip(特殊ip段鏈接數)
設置特殊ip段的每ip鏈接數限制,在connect標籤下面(3.1.1版本以上)。
<connect max_per_ip='0' max='0'>
<per_ip src='ip段' max='鏈接數'/>
<per_ip .../>
</connect>
例,設置192.168.0.0/24每ip鏈接數不限,10.0.0.0/8,拒絕鏈接,其它ip的鏈接數設置爲20,以下配置。
<config>
<connect max_per_ip='20' max='0'>
<per_ip src='192.168.0.0/24' max='0'/>
<per_ip src='10.0.0.0/8' max='deny'/>
</connect>
</config>
request_queue
設置全局請求隊列
<request_queue max_worker='8' max_queue='100'/>
tempfile
設置是否使用臨時文件交換數據
<tempfile>1</tempfile>
如設置使用內存交換
<tempfile>0</tempfile>
max_post_size
設置最大post數據,僅對採用臨時文件交換數據纔有做用
<max_post_size>8M</max_post_size>
buffer
設置數據緩衝區大小
<buffer>32K</buffer>
不建議低於8K
path_info
設置是否啓用path info的支持
<path_info>1</path_info>
cache(緩存)
設置緩存
<cache
default='1'
max_cache_size='1M'
max_bigobj_size='1G'
memory='10M'
disk='10G'
disk_dir='d:\test\'
disk_work_time='* 1-6 * * *'
refresh_time='60'
/>
async_io
設置是否使用異步IO
<async_io>1</async_io>
access_log(全局訪問日誌)
設置全局訪問日誌文件
<access_log>var/access.log</access_log>
access_log_handle
設置訪問日誌處理,每次kangle翻轉訪問日誌時自動調用該命令對日誌進行處理
<access_log_handle><![CDATA[/vhs/kangle/bin/webalizer -F clf -p -Q -o ${log_dir}/../webalizer/ ${log_file}]]></access_log_handle>
如下給個linux下壓縮日誌的例子
<access_log_handle>/usr/bin/gzip ${log_file}</access_log_handle>
log_handle_concurrent
設置訪問日誌處理時,最多併發進程數
<log_handle_concurrent>2</log_handle_concurrent>
log(全局日誌)
設置全局日誌信息
<log
level='3'
rotate_time='0 0 * * *'
rotate_size='100M'
error_rotate_size='100M'
logs_day='30'
logs_size='500M'
log_handle='1'
/>
server_software
設置服務器簽名。
<server_software>簽名</server_software>
如:
<server_software>httpd/2.2</server_software>
hostname
設置服務器名字,用於出錯時,附加到錯誤信息上,方便定位出錯。格式:
<hostname>服務器名</hostname>
worker_io(IO工做者)
設置io最大工做者.
<worker_io>10</worker_io>
worker_dns
admin(web管理)
設置web管理訪問受權(默認是3311端口)
<admin
user='admin'
password='d4b4180809b577da4cadeecb4cd31b67'
crypt='md5'
auth_type='Basic'
admin_ips='127.0.0.1|*'
/>
例:
<admin
user='admin'
password='kangle'
crypt='plain'
auth_type='Basic'
admin_ips='127.0.0.1|*'
/>
server(服務器擴展)
定義一個服務器擴展:
單節點
<server name='kangle' proto='http' host='192.168.1.1' port='80' life_time='0' />
多節點
<server
name='tests'
proto='http'
ip_hash='1'
cookie_stick='1'
error_try_time='30'
max_error_count='5'
>
<node weight='1' host='192.168.1.1' port='80' life_time='0' />
<node weight='1' host='192.168.1.2' port='80' life_time='0' />
</server>
api(api擴展)
定義api擴展,api兼容isapi.爲動態連接庫文件,windows爲dll,linux爲so。
<api name='asp' file='bin/kasp.dll' type='sp' life_time='60'>
</api>
cgi(cgi擴展)
定義cgi擴展,cgi公共網關接口,有關cgi請參考: http://baike.baidu.com/view/369917.htm
<cgi name='php' cmd='/usr/bin/php-cgi' arg='參數' env='環境變量' env_split='|' />
cmd(命令擴展)
vhs(虛擬主機全局)
設置虛擬主機全局的一些配置,位於config標籤下。
<vhs error_404='/404.html'>
其它指令
</vhs>
index(默認文件)
設置默認文件(可放在vhs和vh下面)
<index file='index.php'/>
map(擴展映射)
擴展映射,可在vhs和vh標籤下。格式:
文件擴展名映射
設置按文件擴展名映射
<map file_ext='asp' extend='api:asp' allow_method='*' confirm_file='1' />
按路徑映射
按url的path來映射擴展
<map path='/' extend='擴展' allow_method='*' confirm_file='0'/>
<map path='~\.php$' extend='server:php' allow_method='*' confirm_file='1'/>
alias(別名)
設置虛擬主機別名,可在vhs和vh標籤下。格式:
<alias path='url路徑' to='物理路徑' internal='0或1'/>
例:
<alias path='/aa/' to='D:\project\kangle\www\'/>
mime_type(mime類型)
設置mime類型,可在vhs和vh標籤下。格式:
<mime_type ext='文件擴展名' type='mime類型' gzip='0或1' max_age='緩存時間(秒)'/>
例:
<mime_type ext='html' type='text/html' gzip='1'/>
vh(虛擬主機)
定義一個虛擬主機,在config標籤下。
<vh
name='名字'
doc_root='路徑'
log_file='獨立日誌'
log_rotate_time='0 0 * * *'
log_rotate_size='100m'
inherit='on或off'
user='運行用戶'
group='運行組'
password='密碼'
app='1'
ip_hash='1'
app_share='0或1或2'
browse='on或off'
access='自定義訪問文件'
htaccess='htaccess文件名'
concat='0或1'
max_connect='100'
speed_limit='10240'
fflow='1'
max_worker='10'
max_queue='0'
certificate='ssl證書文件'
certificate_key='ssl證書key文件'
status='狀態'
>
其它指令
</vh>
user,group,password 這個運行身份,僅對擴展cmd和cgi且kangle進程要以超級用戶運行纔有效。即要啓動子進程服務時的一個運行身份。
host(域名綁定)
綁定域名,在vh標籤下,格式:
<host dir='子目錄>域名</host>
例:
<host>*</host>
<host dir='www'>abc.com</host>
bind(ip端口綁定)
綁定到指定ip或端口上(3.1版本),在vh標籤下。格式:
<bind>!ip:port</bind>
例:綁定到80端口和443 ssl端口
<vh 其它配置>
<bind>!*:80</bind>
<bind>!*:443s</bind>
</vh>
index,map,alias,mime_type
vh下的index,map,alias,mime_type請參考vhs下的index,map,alias,mime_type