分享之 Discuz! 的 RewriteRule for Cherokee 

把论坛架在Cherokee上,地址伪静态用的还是apache的,一点一个404……囧rz

现把我设好的重写规则,张贴如下(当然,你也可以自己到控制台设置,也不难)

适用于 一个documentRoot 为 /data/www/web/bbs 的discuz! 7.2 论坛:

vserver!30!document_root = /data/www/web/bbs
vserver!30!error_writer!filename = /usr/local/cherokee/var/log/cherokee.error
vserver!30!error_writer!type = file
vserver!30!keepalive = 1
vserver!30!logger = combined
vserver!30!logger!access!filename = /usr/local/cherokee/var/log/cherokee.access
vserver!30!logger!access!type = file
vserver!30!logger!x_real_ip_access_all = 0
vserver!30!logger!x_real_ip_enabled = 0
vserver!30!match = wildcard
vserver!30!match!domain!1 = bbs.xiazhengxin.*
vserver!30!nick = BBS
vserver!30!rule!1000!handler = redir
vserver!30!rule!1000!handler!rewrite!1!regex = ^/tag-(.+)\.html$
vserver!30!rule!1000!handler!rewrite!1!show = 0
vserver!30!rule!1000!handler!rewrite!1!substring = /tag.php?name=$1
vserver!30!rule!1000!match = request
vserver!30!rule!1000!match!request = ^/tag-(.+)\.html$
vserver!30!rule!1000!no_log = 0
vserver!30!rule!1000!only_secure = 0
vserver!30!rule!900!handler = redir
vserver!30!rule!900!handler!rewrite!1!regex = ^/space-(username|uid)-(.+)\.html$
vserver!30!rule!900!handler!rewrite!1!show = 0
vserver!30!rule!900!handler!rewrite!1!substring = /space.php?$1=$2
vserver!30!rule!900!match = request
vserver!30!rule!900!match!request = ^/space-(username|uid)-(.+)\.html$
vserver!30!rule!900!no_log = 0
vserver!30!rule!900!only_secure = 0
vserver!30!rule!800!handler = redir
vserver!30!rule!800!handler!rewrite!1!regex = ^/archiver/((fid|tid)-[\w\-]+\.html)$
vserver!30!rule!800!handler!rewrite!1!show = 0
vserver!30!rule!800!handler!rewrite!1!substring = /archiver/index.php?$1
vserver!30!rule!800!match = request
vserver!30!rule!800!match!request = ^/archiver/((fid|tid)-[\w\-]+\.html)$
vserver!30!rule!800!no_log = 0
vserver!30!rule!800!only_secure = 0
vserver!30!rule!700!handler = redir
vserver!30!rule!700!handler!rewrite!1!regex = ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$
vserver!30!rule!700!handler!rewrite!1!show = 0
vserver!30!rule!700!handler!rewrite!1!substring = /viewthread.php?tid=$1&extra=page\=$3&page=$2
vserver!30!rule!700!match = request
vserver!30!rule!700!match!request = ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$
vserver!30!rule!700!no_log = 0
vserver!30!rule!700!only_secure = 0
vserver!30!rule!600!handler = redir
vserver!30!rule!600!handler!rewrite!1!regex = ^/forum-([0-9]+)-([0-9]+)\.html$
vserver!30!rule!600!handler!rewrite!1!show = 0
vserver!30!rule!600!handler!rewrite!1!substring = /forumdisplay.php?fid=$1&page=$2
vserver!30!rule!600!match = request
vserver!30!rule!600!match!request = ^/forum-([0-9]+)-([0-9]+)\.html$
vserver!30!rule!600!no_log = 0
vserver!30!rule!600!only_secure = 0
vserver!30!rule!500!disabled = 0
vserver!30!rule!500!encoder!gzip = 1
vserver!30!rule!500!handler = fcgi
vserver!30!rule!500!handler!balancer = round_robin
vserver!30!rule!500!handler!balancer!source!1 = 1
vserver!30!rule!500!handler!error_handler = 1
vserver!30!rule!500!match = extensions
vserver!30!rule!500!match!extensions = php
vserver!30!rule!500!match!final = 1
vserver!30!rule!500!timeout = 30
vserver!30!rule!400!disabled = 0

_____________

把代码粘贴入cherokee.conf 相对位置即可.
[ ] ( 2034 次浏览 ) 永久链接 ( 3 / 2242 )
编译安装 php 5.3.2 和 fastcgi 2.4.1-SNAP-0910052249 通过 

有了空闲的免费VPS,于是就寻思把我那下线已久的“小鑫论坛”重新上线……
顺便把我昨天安装的Cherokee变成支持cgi的服务器,于是就行动了
本来是想下载5.2.13的,因为我的小鑫论坛是架在Discuz!上的,而php 5.3.1 不兼容 Discuz! 7.x.
ps:就这点,本人也曾向Discuz!开发组反应过,地址:http://code.google.com/p/discuzdeveloper/issues/detail?id=1.
可是听说网友用php 5.3.x 测试一切正常了现在。
于是便下载了最新的 php 5.3.2版
http://cn.php.net/distributions/php-5.3.2.tar.bz2

以及fastcgi最新的Snap版:
http://www.fastcgi.com/dist/fcgi-2.4.1-SNAP-0910052249.tar.gz
之所以选择fastcgi,是因为它官方网站上说支持Cherokee,
见:http://www.fastcgi.com/drupal/node/3

我的configure:
fastcgi:
$ ./configure --prefix=/usr/local/fcgi --bindir=/usr/local/bin --sbindir=/usr/local/sbin

make && make install.一切OK

下面是php的;
# ./configure --prefix=/usr/local/php --bindir=/usr/local/bin --sbindir=/usr/local/sbin --enable-safe-mode --with-zlib --with-bz2 --with-curl --enable-exif --enable-ftp --with-gd --with-mhash --enable-mbstring --with-mcrypt --with-mysql --with-mysql-sock --enable-embedded-mysqli --with-pdo-mysql=/usr/local/mysql --enable-sockets --with-xmlrpc --enable-zip

看遍了帮助文档,居然没有找到任何与fastcgi搭边的参数,囧rz...

直接用php-cgi吧

编译报错,提示缺少libmcrypt 库.
本想直接 yum install libmcrypt,可是火山互联居然不让连外网~~
只好下载源码再通过ftp上传到VPS。。。

解压,定位到目录.直接 ./configure && make && make install

再次检查依赖,通过.

然后 make && make install. 等了好久,安装成功.别忘了配置文件 php.ini.

最后,cherokee-admin -b -p 80 -u ,登录服务器控制台。
在虚拟目录的扩展里面添加语言php,启用,保存即可.

启动Cherokee,phpinfo()已经可以正常识别与显示.
[ ] ( 1971 次浏览 ) 永久链接 ( 2.9 / 2314 )
编译安装 Cherokee web server 0.99.44b 通过 

最近拿火山互联的免费VPS搞着玩,卸掉了自带的apache,想尝试下号称速度最快的Cherokee web server,反正也闲来无事.
对它是耳闻已久了,就是一直没有时间,关键是没有空闲的机器去尝试尝试。呵呵

下载最新版本;http://ftp.saix.net/Cherokee/LATEST_is_0.99.43/cherokee-0.99.43.tar.gz

解压,简单了看了下README 和 INSTALL.给我感觉,不像apache 那样冗长,动不动就几百上千行。
看得眼花。这个很快就到达bottom了。。

cherokee 给的参数很少,所以编译安装起来很方便.

我的configure:
It was created by cherokee configure '0.99.44', which was
generated by GNU Autoconf 2.65. Invocation command line was

$ ./configure --prefix=/usr/local/cherokee --bindir=/usr/local/bin --sbindir=/usr/local/sbin --enable-beta --enable-os-string=PowerPC --enable-trace --enable-internal-pcre --enable-static-module=ALL --with-wwwroot=/home/www/web --with-wwwuser=vhost --with-wwwgroup=vhost

一切顺利.
完了后给出结果列表:
============================
Install prefix /usr/local/cherokee
CFLAGS -g -O2
trace yes
backtracing no
sendfile() yes
IPv6 support yes
Polling method 1 epoll
Polling method 2 poll
Polling method 3 select
Threading support yes
OpenSSL support yes
PCRE library built-in
Compatible PAM yes
LDAP yes
MySQL yes
GeoIP no
FFMpeg no
crypt support multithread
Beta release

Installation dir /usr/local/bin

最后, make && make install.

安装完成.

cherokee 最大的好处就是不用编辑配置文件,而是通过一个可视化的控制台去操作。很是方便.

由于火山互联不支持80、21外其他端口,且登录验证总是出错.

故运行 cherokee-admin -b -p 80 -u ,直接 "http://域名" 无密码访问.(不太安全)
设置好虚拟主机,保存即可.

退出cherokee-admin程序,这样就算配置好了,方便呀

由于,火山互联VPS默认的php没有编译支持cgi,所以…… 杯具呀
改天再弄吧

输入 cherokee -d 运行服务器。
[ ] ( 1932 次浏览 ) 永久链接 ( 3 / 2574 )
经典的apache 配置文件 

最近偶然发现火山互联的免费VPS又开放注册了.于是便注册用了一下。
比起去年的那个多了很多限制,如远程服务器的ssh、ftp、wget、curl 集体挂掉,连ping 也ping不通了……

默认还是apache + mysql + php + pureftpd 经典搭配.

本想移除apache,发现它的httpd.conf 配置还算比较经典,值得一般人采用.

张贴如下;

Listen 80
ServerName 127.0.0.1
ServerRoot "/usr/local/apache2"
DocumentRoot "/usr/local/apache2/htdocs"
ServerTokens Full
ServerSignature On
DefaultIcon /icons/unknown.gif
DefaultType text/plain
TypesConfig conf/mime.types
IndexOptions FancyIndexing VersionSort
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
ForceLanguagePriority Prefer Fallback

DirectoryIndex index.html index.htm index.php
AccessFileName .htaccess


Timeout 300
KeepAlive Off
UseCanonicalName Off
HostnameLookups Off


ExtendedStatus On
<Location /myserverstatus>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from all
</Location>

#LoadModule include_module modules/mod_include.so
#LoadModule deflate_module modules/mod_deflate.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule info_module modules/mod_info.so
#LoadModule cgid_module modules/mod_cgid.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule fastcgi_module modules/mod_fastcgi.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule headers_module modules/mod_headers.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbd_module modules/mod_authn_dbd.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule dbd_module modules/mod_dbd.so
LoadModule dumpio_module modules/mod_dumpio.so
LoadModule filter_module modules/mod_filter.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule asis_module modules/mod_asis.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule imagemap_module modules/mod_imagemap.so
LoadModule actions_module modules/mod_actions.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule bw_module modules/mod_bw.so
LoadModule php5_module modules/libphp5.so

<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
User vhost
Group vhost
</IfModule>
</IfModule>

<IfModule prefork.c>
StartServers 50
MinSpareServers 20
MaxSpareServers 50
ServerLimit 1000
MaxClients 800
MaxRequestsPerChild 10000
</IfModule>


<IfModule worker.c>
StartServers 5
ServerLimit 200
MaxClients 1000
MinSpareThreads 25
MaxSpareThreads 50
ThreadsPerChild 5
MaxRequestsPerChild 10000
</IfModule>

<IfModule mod_mime_magic.c>
MIMEMagicFile conf/magic
</IfModule>

<IfModule !mpm_netware_module>
PidFile logs/httpd.pid
</IfModule>

<IfModule !mpm_winnt_module>
<IfModule !mpm_netware_module>
LockFile logs/accept.lock
</IfModule>
</IfModule>




Alias /icons/ "/usr/local/apache2/icons/"
AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|ru))?(/.*)?$ "/usr/local/apache2/manual$1"

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "/usr/local/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>

<FilesMatch "\.(exe|com|vbs|vbe|bat|mdb|sql|wml)$">
Order allow,deny
Deny from all
</FilesMatch>



AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler type-map var
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8 .utf8
AddCharset GB2312 .gb2312 .gb
AddCharset utf-7 .utf7
AddCharset utf-8 .utf8
AddCharset big5 .big5 .b5
AddCharset EUC-TW .euc-tw
AddCharset EUC-JP .euc-jp
AddCharset EUC-KR .euc-kr
AddCharset shift_jis .sjis

BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully


#LogLevel emerg
#LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Host}i\" \"%{Referer}i\" \"%{User-agent}i\"" common
#customlog "|/usr/local/apache2/bin/rotatelogs /var/log/httpd/access_%y_%m_%d_%H.log 3600 480" common


bandwidthmodule on

NameVirtualHost *

Include "/usr/local/apache2/conf/vhost.conf"

vhost.conf 内容;
#mysql.demo.com BEGIN
<VirtualHost *>
DocumentRoot /data/www/web/err/phpmyadmin
ServerName mysql.demo.com
php_admin_value open_basedir /data/www/web/err/phpmyadmin
php_admin_value upload_tmp_dir /data/www/web/err/phpmyadmin
</VirtualHost>
#mysql.demo.com END

#vhost.demo.com BEGIN
<VirtualHost *>
ErrorDocument 404 error.html
DirectoryIndex index.html
DocumentRoot /data/www/web/vhost
ServerName vhost.com
ServerAlias vhost.demo.com
php_admin_value open_basedir /data/www/web/vhost
php_admin_value upload_tmp_dir /data/www/web/vhost
</VirtualHost>
#vhost.demo.com END
[ ] ( 3785 次浏览 ) 永久链接 ( 3 / 2545 )
让你的服务器更安全的20个配置[转] 

当然,这只针对于apache httpd server。不过其中的一些方面,同样适用于nginx、lighttpd、cherokee、hiawatha等非主流服务器系统.

1.首先确保已经打好了全部已知安全补丁....

2.隐藏掉服务器的版本等敏感信息.
ServerSignature Off
ServerTokens Prod

3.确保httpd是以它自己的用户和组在运行.
User apache
Group apache

4.确保只有网站根目录下的文件才可以通过web被访问.
<Directory />
Order Deny,Allow
Deny from all
Options None #这个可以被局部参数覆盖
AllowOverride None #这个可以被局部参数覆盖
</Directory>

5.关闭目录结构列表
Options -Indexes

6.关闭服务器端的配置文件包括
Options -Includes

7.关闭CGI执行本地脚本(真的很危险)
Options -ExecCGI

8.关闭软链
Options -FollowSymLinks

9.如果可以的话,建议关闭Options 的所有功能.
Options None

或者综上四点所述
Options -ExecCGI -FollowSymLinks -Indexes

10.关闭.htaccess 支持
AllowOverride None

如果必须启用的话可以考虑改名,并限制访问
AccessFileName .httpdoverride
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>

11.确保httpd已载入mod_security模块,并运行.
LoadModule mod_security mod_security.so
下载地址:http://www.modsecurity.org/

12.去除掉不需要的模块.
可以使用 grep LoadModule httpd.conf 查看所有模块.

下面是一些通常不需要的而普遍被启用的模块:
mod_imap, mod_include, mod_info, mod_userdir, mod_status, mod_cgi, mod_autoindex.

13.确保只有root拥有对httpd配置文件和程序文件的读写权限.
chown -R root:root /path/to/apache
chmod -R o-rwx /path/to/apache

14.减少请求超时时间间隔
Timeout 45 #默认是300s

15.限制请求体大小,以防超大文件
LimitRequestBody 1048576

同样作用的配置还有:
LimitRequestFields, LimitRequestFieldSize 和 LimitRequestLine

16.限制XML请求体的大小
LimitXMLRequestBody 10485760
当然,这只适用于apache httpd 集成了SVN的服务器.

17.限制并发请求
MaxClients ??? #根据各自服务器内存适量设置

相关的配置项:
MaxSpareServers, MaxRequestsPerChild
ThreadsPerChild, ServerLimit,MaxSpareThreads 适用于apache2.x

18.限制IP访问
Order Deny,Allow
Deny from all
Allow from 127.0.0.1

19.调节保持存活时间
MaxKeepAliveRequests ??? #根据各自服务器内存适量设置
KeepAliveTimeout ??? #根据各自服务器内存适量设置

20.确保httpd运行在chroot 环境
SecChrootDir /chroot/apache

这样,apache httpd 就运行在虚拟的系统里,就算被hack了,也不会影响到真实系统.

___END___

这篇文章是我最近一不小心看到的,虽然是发表于2005年,有点过时了.囧rz
不过觉得很有帮助.特别是网络管理员来讲.

原文地址:20 ways to Secure your Apache Configuration
[ ] ( 1879 次浏览 ) 永久链接 ( 3 / 2753 )

<< <上一页 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 下一页> >>