千万个美丽的未来,抵不上一个温暖的现在,每一个真实的现在,都是我们曾经幻想的未来!
Mar
11
WordPress
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
WordPress Mu
location /{
server_name_in_redirect off;
port_in_redirect off;
rewrite ^.*/files/(.*) /wp-includes/ms-files.php?file=$1;
rewrite ^/files/(.+) /wp-includes/ms-files.php?file=$1;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
Drupal
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
Twip
location /{
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php last;
}
}
Typecho
location / {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
Discuz
location / {
rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
}
Discuz X
location / {
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
if (!-e $request_filename) {
return 404;
}
}
Dabr
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
SaBlog
location / {
rewrite “^/date/([0-9]{6})/?([0-9]+)?/?$” /index.php?action=article&setdate=$1&page=$2 last;
rewrite ^/page/([0-9]+)?/?$ /index.php?action=article&page=$1 last;
rewrite ^/category/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&cid=$1&page=$2 last;
rewrite ^/category/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&curl=$1&page=$2 last;
rewrite ^/(archives|search|article|links)/?$ /index.php?action=$1 last;
rewrite ^/(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ /index.php?action=$1&page=$2 last;
rewrite ^/tag/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&item=$1&page=$2 last;
rewrite ^/archives/([0-9]+)/?([0-9]+)?/?$ /index.php?action=show&id=$1&page=$2 last;
rewrite ^/rss/([^/]+)/?$ /rss.php?url=$1 last;
rewrite ^/user/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&user=$1&page=$2 last;
rewrite sitemap.xml sitemap.php last;
rewrite ^(.*)/([0-9a-zA-Z\-\_]+)/?([0-9]+)?/?$ $1/index.php?action=show&alias=$2&page=$3 last;
}
Xnote
location / {
if (!-e $request_filename) {
rewrite "^/([A-Za-z0-9\-]{4,20})$" /index.php?url=$1 last;
}
}
Status.net
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
PHP-Wind
location / {
rewrite ^thread-htm-tid-(\d+)-(.*).html thread.php?fid=$1 last;
rewrite ^read-htm-tid-(\d+)-(.*).html read.php?tid=$1 last;
rewrite ^commtopics-(.*)-(.*) thread.php?fid=$1&page=$2 last;
rewrite ^commtopics-(.*) thread.php?fid=$1&page=$2 last;
rewrite ^article-(.*)-(.*)-(.*).html read.php?tid=$1&page=$2&fpage=$3 last;
rewrite ^article-(.*)-(.*).html read.php?tid=$1&page=$2&fpage=$3 last;
rewrite ^article-(.*).html read.php?tid=$1 last;
rewrite ^read-htm-tid-(\d+)-(.*).html read.php\?tid=$1 last;
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
rewrite ^(.*)/u/([0-9]+)$ $1/u.php?uid=$2 last;
}
Bo-Blog
location / {
if (!-e $request_filename)
{
rewrite ^/post/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?entryid=$1&page=$2&part=$3 last;
rewrite ^/page/([0-9]+)/([0-9]+)/?$ /index.php?mode=$1&page=$2 last;
rewrite ^/starred/([0-9]+)/?([0-9]+)?/?$ /star.php?mode=$1&page=$2 last;
rewrite ^/category/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=category_$1&mode=$2&page=$3 last;
rewrite ^/archiver/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=archive&cm=$1&cy=$2&mode=$3&page=$4 last;
rewrite ^/date/([0-9]+)/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=showday_$1-$2-$3&mode=$4&page=$5 last;
rewrite ^/user/([0-9]+)/?$ /view.php?go=user_$1 last;
rewrite ^/tags/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /tag.php?tag=$1&mode=$2&page=$3 last;
rewrite ^/component/id/([0-9]+)/?$ /page.php?pageid=$1 last;
rewrite ^/component/([^/]+)/?$ /page.php?pagealias=$1 last;
#Force redirection for old rules
rewrite ^/read\.php/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/$3/ permanent;
rewrite ^/index\_([0-9]+)\_([0-9]+)\.htm$ http://$host/page/$1/$2/ permanent;
rewrite ^/star\_([0-9]+)\_([0-9]+)\.htm$ http://$host/starred/$1/$2/ permanent;
rewrite ^/category\_([0-9]+)\.htm$ http://$host/category/$1/ permanent;
rewrite ^/category\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/category/$1/$2/$3/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/$3/$4/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/$4/$5/ permanent;
#Filename alias
rewrite ^/([a-zA-Z0-9_-]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?blogalias=$1&page=$2&part=$3 last;
}
}
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
WordPress Mu
location /{
server_name_in_redirect off;
port_in_redirect off;
rewrite ^.*/files/(.*) /wp-includes/ms-files.php?file=$1;
rewrite ^/files/(.+) /wp-includes/ms-files.php?file=$1;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
Drupal
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
Twip
location /{
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php last;
}
}
Typecho
location / {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
Discuz
location / {
rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
}
Discuz X
location / {
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
if (!-e $request_filename) {
return 404;
}
}
Dabr
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
SaBlog
location / {
rewrite “^/date/([0-9]{6})/?([0-9]+)?/?$” /index.php?action=article&setdate=$1&page=$2 last;
rewrite ^/page/([0-9]+)?/?$ /index.php?action=article&page=$1 last;
rewrite ^/category/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&cid=$1&page=$2 last;
rewrite ^/category/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&curl=$1&page=$2 last;
rewrite ^/(archives|search|article|links)/?$ /index.php?action=$1 last;
rewrite ^/(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ /index.php?action=$1&page=$2 last;
rewrite ^/tag/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&item=$1&page=$2 last;
rewrite ^/archives/([0-9]+)/?([0-9]+)?/?$ /index.php?action=show&id=$1&page=$2 last;
rewrite ^/rss/([^/]+)/?$ /rss.php?url=$1 last;
rewrite ^/user/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&user=$1&page=$2 last;
rewrite sitemap.xml sitemap.php last;
rewrite ^(.*)/([0-9a-zA-Z\-\_]+)/?([0-9]+)?/?$ $1/index.php?action=show&alias=$2&page=$3 last;
}
Xnote
location / {
if (!-e $request_filename) {
rewrite "^/([A-Za-z0-9\-]{4,20})$" /index.php?url=$1 last;
}
}
Status.net
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
PHP-Wind
location / {
rewrite ^thread-htm-tid-(\d+)-(.*).html thread.php?fid=$1 last;
rewrite ^read-htm-tid-(\d+)-(.*).html read.php?tid=$1 last;
rewrite ^commtopics-(.*)-(.*) thread.php?fid=$1&page=$2 last;
rewrite ^commtopics-(.*) thread.php?fid=$1&page=$2 last;
rewrite ^article-(.*)-(.*)-(.*).html read.php?tid=$1&page=$2&fpage=$3 last;
rewrite ^article-(.*)-(.*).html read.php?tid=$1&page=$2&fpage=$3 last;
rewrite ^article-(.*).html read.php?tid=$1 last;
rewrite ^read-htm-tid-(\d+)-(.*).html read.php\?tid=$1 last;
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
rewrite ^(.*)/u/([0-9]+)$ $1/u.php?uid=$2 last;
}
Bo-Blog
location / {
if (!-e $request_filename)
{
rewrite ^/post/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?entryid=$1&page=$2&part=$3 last;
rewrite ^/page/([0-9]+)/([0-9]+)/?$ /index.php?mode=$1&page=$2 last;
rewrite ^/starred/([0-9]+)/?([0-9]+)?/?$ /star.php?mode=$1&page=$2 last;
rewrite ^/category/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=category_$1&mode=$2&page=$3 last;
rewrite ^/archiver/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=archive&cm=$1&cy=$2&mode=$3&page=$4 last;
rewrite ^/date/([0-9]+)/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=showday_$1-$2-$3&mode=$4&page=$5 last;
rewrite ^/user/([0-9]+)/?$ /view.php?go=user_$1 last;
rewrite ^/tags/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /tag.php?tag=$1&mode=$2&page=$3 last;
rewrite ^/component/id/([0-9]+)/?$ /page.php?pageid=$1 last;
rewrite ^/component/([^/]+)/?$ /page.php?pagealias=$1 last;
#Force redirection for old rules
rewrite ^/read\.php/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/$3/ permanent;
rewrite ^/index\_([0-9]+)\_([0-9]+)\.htm$ http://$host/page/$1/$2/ permanent;
rewrite ^/star\_([0-9]+)\_([0-9]+)\.htm$ http://$host/starred/$1/$2/ permanent;
rewrite ^/category\_([0-9]+)\.htm$ http://$host/category/$1/ permanent;
rewrite ^/category\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/category/$1/$2/$3/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/$3/$4/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/$4/$5/ permanent;
#Filename alias
rewrite ^/([a-zA-Z0-9_-]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?blogalias=$1&page=$2&part=$3 last;
}
}
Feb
20
与apache的规则不同,CodeIgniter在nginx服务器的伪静态(rewrite)规则如下:
user www www;
worker_processes 8;
error_log /var/log/nginx_error.log crit;
pid /usr/local/nginx/nginx.pid;
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
server
{
listen 80;
server_name 192.168.10.60;
root /PATH/TO/YOUR/CI/FORLDER;
index index.html index.htm index.php index.shtml;
if ($request_filename !~* /(javascript|css|images|fckeditor|userfiles|crontab|robots\.txt|index\.php))
{
rewrite ^/(.*)$ /index.php?$1 last;
}
access_log /var/log/192.168.10.60-access.log;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht
{
deny all;
}
}
}
user www www;
worker_processes 8;
error_log /var/log/nginx_error.log crit;
pid /usr/local/nginx/nginx.pid;
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
server
{
listen 80;
server_name 192.168.10.60;
root /PATH/TO/YOUR/CI/FORLDER;
index index.html index.htm index.php index.shtml;
if ($request_filename !~* /(javascript|css|images|fckeditor|userfiles|crontab|robots\.txt|index\.php))
{
rewrite ^/(.*)$ /index.php?$1 last;
}
access_log /var/log/192.168.10.60-access.log;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht
{
deny all;
}
}
}
May
16
nginx添加参数可以允许打开目录浏览功能,详见http://bbs.linuxtone.org/viewthread.php?tid=2563&rpid=9073&ordertype=0&page=1#pid9073或者
官方的 http://wiki.nginx.org/NginxHttpAutoindexModule
这是说的是支持目录浏览的第三方插件fancyindex
本次试验用的nginx-0.8.15
第三方插件下载地址
http://download.snake.de/dist/ngx-fancyindex-0.2.1.tar.bz2
[root@test src]# tar zxvf nginx-0.8.15.tar.gz
[root@test src]# tar jxvf ngx-fancyindex-0.2.1.tar.bz2
[root@test src]# cd nginx-0.8.15
[root@test nginx-0.8.15]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=../ngx-fancyindex-0.2.1
然后根据自己的目录浏览要求配置 nginx.conf ,以下为我的主机配置
[root@test nginx]# ./sbin/nginx -t
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@test nginx]# ./sbin/nginx
完成配置。
这里只是用到了插件fancyindex的2个参数,还有 fancyindex_localtime ,fancyindex_header, fancyindex_footer = 大家研究一下。。可以看一下这里 http://wiki.nginx.org/NginxNgxFancyIndex 。
不知道 安装这个插件与没有安装过插件开启,在效率上是否有不同。。。
下面截图是 安装过插件 和nginx 开启目录浏览 截图。
官方的 http://wiki.nginx.org/NginxHttpAutoindexModule
这是说的是支持目录浏览的第三方插件fancyindex
本次试验用的nginx-0.8.15
第三方插件下载地址
http://download.snake.de/dist/ngx-fancyindex-0.2.1.tar.bz2
[root@test src]# tar zxvf nginx-0.8.15.tar.gz
[root@test src]# tar jxvf ngx-fancyindex-0.2.1.tar.bz2
[root@test src]# cd nginx-0.8.15
[root@test nginx-0.8.15]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=../ngx-fancyindex-0.2.1
然后根据自己的目录浏览要求配置 nginx.conf ,以下为我的主机配置
引用
server {
listen 80;
server_name 192.168.11.12;
location / {
fancyindex on;#开启 fancy indexes
fancyindex_exact_size off;#显示文件大小。
# autoindex on;
#autoindex_localtime on;
#autoindex_exact_size off; 注释这三项是不装插件开启目录浏览功能。
root /data ;
}
}
listen 80;
server_name 192.168.11.12;
location / {
fancyindex on;#开启 fancy indexes
fancyindex_exact_size off;#显示文件大小。
# autoindex on;
#autoindex_localtime on;
#autoindex_exact_size off; 注释这三项是不装插件开启目录浏览功能。
root /data ;
}
}
[root@test nginx]# ./sbin/nginx -t
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@test nginx]# ./sbin/nginx
完成配置。
这里只是用到了插件fancyindex的2个参数,还有 fancyindex_localtime ,fancyindex_header, fancyindex_footer = 大家研究一下。。可以看一下这里 http://wiki.nginx.org/NginxNgxFancyIndex 。
不知道 安装这个插件与没有安装过插件开启,在效率上是否有不同。。。
下面截图是 安装过插件 和nginx 开启目录浏览 截图。
May
16
LVS:略
nginx proxy 配置:
location / {
root /data/www/wwwroot/bbs.linuxtone.com;
proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_pass http://bbs.linuxtone.org;
}
源nginx配置:
安装
HttpRealIpModule模块:
http://wiki.nginx.org/NginxChsHttpRealIpModule
--with-http_realip_module
编译方法:
./configure --user=daemon --group=daemon --prefix=/usr/local/nginx/
--with-http_stub_status_module --with-http_ssl_module
--with-http_sub_module --with-md5=/usr/lib --with-sha1=/usr/lib
--with-http_gzip_static_module --with-http_realip_module
虚拟主机增加配置:
set_real_ip_from nginx_proxy_ip/24;
set_real_ip_from nginx_proxy_ip;
real_ip_header X-Real-IP;
EXP:
set_real_ip_from 192.168.1.0/24;
set_real_ip_from 192.168.1.6;
real_ip_header X-Real-IP;
查看二台nginx的日志就能取到真实IP了
nginx proxy 配置:
引用
location / {
root /data/www/wwwroot/bbs.linuxtone.com;
proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_pass http://bbs.linuxtone.org;
}
源nginx配置:
安装
HttpRealIpModule模块:
http://wiki.nginx.org/NginxChsHttpRealIpModule
--with-http_realip_module
编译方法:
引用
./configure --user=daemon --group=daemon --prefix=/usr/local/nginx/
--with-http_stub_status_module --with-http_ssl_module
--with-http_sub_module --with-md5=/usr/lib --with-sha1=/usr/lib
--with-http_gzip_static_module --with-http_realip_module
虚拟主机增加配置:
set_real_ip_from nginx_proxy_ip/24;
set_real_ip_from nginx_proxy_ip;
real_ip_header X-Real-IP;
EXP:
set_real_ip_from 192.168.1.0/24;
set_real_ip_from 192.168.1.6;
real_ip_header X-Real-IP;
查看二台nginx的日志就能取到真实IP了
May
16
有时候为了伪装自己的真实服务器环境.
不想让对方知道自己的webserver真实环境,就不得不修改我们的webserer软件了!
今天看了一下baidu.com的webserver感觉像是nginx修改的.
C:\curl-7.18.0\curl.exe -I www.baidu.com
HTTP/1.1 200 OK
Date: Tue, 11 Mar 2008 05:00:39 GMT
Server: BWS/1.0
Content-Length: 3022
Content-Type: text/html
Cache-Control: private
Expires: Tue, 11 Mar 2008 05:00:39 GMT
Set-Cookie: BAIDUID=41BB2845D3E8BC1AEE99D4CECB90C50A:FG=1; expires=Tue, 11-
8 05:00:39 GMT; path=/; domain=.baidu.com
P3P: CP=" OTI DSP COR IVA OUR IND COM "
于是自己翻了一下nginx源码了,发现竟然很容修改就可以实现.
cd /usr/local/src/nginx-0.5.35/src/core/
[root@zyatt core]# cat nginx.h
/*
* Copyright (C) Igor Sysoev
*/
#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_
#define NGINX_VERSION "1.0"
#define NGINX_VER "LPKWS/" NGINX_VERSION
#define NGINX_VAR "LPKWS"
#define NGX_OLDPID_EXT ".oldbin"
#endif /* _NGINX_H_INCLUDED_ */
测试效果
C:\curl-7.18.0\curl.exe -I 211.100.11.122/info.php (此Nginx没有做优化,配置expires,gzip等,仅为测试)
HTTP/1.1 200 OK
Server: LPKWS/1.0
Date: Tue, 11 Mar 2008 04:53:02 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
X-Powered-By: PHP/5.2.4
要想更彻底点,把下面这几个文件也修改了
修改src/http/ngx_http_header_filter_module.c
static char ngx_http_server_string[]="Server: nginx" CRLF;
修改src/http/ngx_http_special_response.c
static u_char ngx_http_error_tail[]="<hr><center>nginx</center>" CRLF"</body>" CRLF"</html>" CRLF;
修改Nginx的FastCGI配置文件fastcgi.conf
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
要想真正的优化和安全考虑,还是应该好好读读源代码,踏踏实实做好细节工作!
不想让对方知道自己的webserver真实环境,就不得不修改我们的webserer软件了!
今天看了一下baidu.com的webserver感觉像是nginx修改的.
C:\curl-7.18.0\curl.exe -I www.baidu.com
HTTP/1.1 200 OK
Date: Tue, 11 Mar 2008 05:00:39 GMT
Server: BWS/1.0
Content-Length: 3022
Content-Type: text/html
Cache-Control: private
Expires: Tue, 11 Mar 2008 05:00:39 GMT
Set-Cookie: BAIDUID=41BB2845D3E8BC1AEE99D4CECB90C50A:FG=1; expires=Tue, 11-
8 05:00:39 GMT; path=/; domain=.baidu.com
P3P: CP=" OTI DSP COR IVA OUR IND COM "
于是自己翻了一下nginx源码了,发现竟然很容修改就可以实现.
cd /usr/local/src/nginx-0.5.35/src/core/
[root@zyatt core]# cat nginx.h
/*
* Copyright (C) Igor Sysoev
*/
#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_
#define NGINX_VERSION "1.0"
#define NGINX_VER "LPKWS/" NGINX_VERSION
#define NGINX_VAR "LPKWS"
#define NGX_OLDPID_EXT ".oldbin"
#endif /* _NGINX_H_INCLUDED_ */
测试效果
C:\curl-7.18.0\curl.exe -I 211.100.11.122/info.php (此Nginx没有做优化,配置expires,gzip等,仅为测试)
HTTP/1.1 200 OK
Server: LPKWS/1.0
Date: Tue, 11 Mar 2008 04:53:02 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
X-Powered-By: PHP/5.2.4
要想更彻底点,把下面这几个文件也修改了
修改src/http/ngx_http_header_filter_module.c
static char ngx_http_server_string[]="Server: nginx" CRLF;
修改src/http/ngx_http_special_response.c
static u_char ngx_http_error_tail[]="<hr><center>nginx</center>" CRLF"</body>" CRLF"</html>" CRLF;
修改Nginx的FastCGI配置文件fastcgi.conf
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
要想真正的优化和安全考虑,还是应该好好读读源代码,踏踏实实做好细节工作!