全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 24509|回复: 53
打印 上一主题 下一主题

nginx静态规则这样添加为何不行,该如何改

[复制链接]
跳转到指定楼层
1#
发表于 2009-10-12 20:16:20 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
server
        {
                listen  80;
                server_name  host1.moltown.com;

                location / {
                        stub_status on;
                        access_log   off;
                                 }

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;
            break;
        }


if ($host != 'moltown.com/my' ) {
        rewrite  ^/(.*)$  http://moltown.com/my/$1  permanent;
  }
  
        rewrite ^/(post|record|sort|author|page)-([0-9]+)\.html$ /index.php?$1=$2;
        rewrite ^/tag-(.+)\.html$ /index.php?tag=$1;
            }

     }

测试出现[emerg]: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:103
configuration file /usr/local/nginx/conf/nginx.conf test failed
我看别人都这样插入静态规则的...怎么就不能重复呢
54#
发表于 2009-10-13 00:27:37 | 只看该作者

回复 53# 的帖子

53#
 楼主| 发表于 2009-10-13 00:25:26 | 只看该作者

回复 52# 的帖子

法科DZ,不过还是再次感谢,受教了
52#
发表于 2009-10-13 00:22:23 | 只看该作者

回复 51# 的帖子

可能是discuz 7.1的伪静态规则跟6.0不一样了吧。
51#
 楼主| 发表于 2009-10-13 00:16:17 | 只看该作者
worker_processes 1;

error_log  /home/logs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
        {
                use epoll;
                worker_connections 51200;
        }

http
        {
                include       mime.types;
                default_type  application/octet-stream;

                #charse  gb2312;

                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;

                #limit_zone  crawler  $binary_remote_addr  10m;

server
        {
                listen       80;
                server_name www.moltown.com moltown.com;
                index index.html index.htm index.php;
                root  /home/www;

                #limit_conn   crawler  20;

                #location /status {
                #stub_status        on;
                #access_log        off;
                #}

location /bbs {
            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;
            break;
        }

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                #fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
                access_log  /home/logs/access.log  access;

        }
}

如上,去掉emlog那个rewrite,测试通过,kill -HUP `cat /usr/local/nginx/logs/nginx.pid`之后依然打不开....绝望了...看来是DZ7.1的原因
50#
发表于 2009-10-13 00:14:42 | 只看该作者

回复 49# 的帖子

慢玩啊 我去捣鼓 我的 vps去了
然后 (~ o ~)~zZ 去 嘿嘿
49#
发表于 2009-10-13 00:11:19 | 只看该作者
原帖由 zyypp 于 2009-10-13 00:08 发表
dz 的 问 C大 他用的有


我给的32楼的,完全正确的,应该没问题的。
48#
发表于 2009-10-13 00:09:30 | 只看该作者

回复 46# 的帖子

搞个试验 你把博客那段伪静态规则删除掉,然后重新加载下nginx.conf 看下你的博客伪静态是否还成功
47#
发表于 2009-10-13 00:08:13 | 只看该作者
dz 的 问 C大 他用的有
46#
 楼主| 发表于 2009-10-13 00:07:01 | 只看该作者

回复 43# 的帖子

emlog的rewrite是对的啊,我屡试不爽,就是DZ测试通过,还装死,不过我用的是DZ7.1,还没出正式版
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-10-27 01:43 , Processed in 0.079030 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表