惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
Last Week in AI
Last Week in AI
T
Tailwind CSS Blog
V
Visual Studio Blog
Jina AI
Jina AI
博客园 - 司徒正美
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
小众软件
小众软件
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
WordPress大学
WordPress大学
爱范儿
爱范儿
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏

博客园 - wenanry

让免费游戏带来回报的15种方法 乐趣是核心 devenv.exe - 系统错误无法启动此程序,因为计算机中丢失 MSVCR100.dll。尝试重新安装该程序以解决此问题。【解决办法】 Ubuntu下的PHP开发环境架设 Dpkg 常用指令操作快速参考 WineQQ 最新解决方案:WineQQ2012 Beta2 互联网创业降级论 consistent hashing in C# linux redhat Centos debian 破解root 密码 “Give root password for maintenance” Linux 脚本编写基础 linux一些基本命令以及初级网络配置 linux修改ssh端口和禁止root远程登陆设置 Nginx启动出错 error while loading shared libraries: 安装Nginx时报错 the HTTP cache module requires md5 functions pcre-8.20编译安装出错[pcrecpp.lo] Error 1 使用Tomcat配置域名 yum升级提示TypeError: unsubscriptable object Redis相关指令文档 Redis配置文件参数说明 Redis在Windows+linux平台下的安装配置
Nginx中URL不区分大小写
wenanry · 2012-04-16 · via 博客园 - wenanry

1.需要Embedded Perl模块支持

  本模块允许在Nginx中直接执行Prel,或者通过SSI调用Perl。

  默认是不会编译进Nginx的,如果你要使用,则要在编译安装Nginx指定:

./configure  --with-http_perl_module

  另外:操作系统中必须安装:Perl5.6.1以上版本

已知问题:

    1 ) 如果Perl模块执行长时间操作,例如:DNS查询、数据库查询等,运行Perl脚本的工作进程将一直处于阻塞状态,因此内置的Perl脚本应该非常简单,执行尽可能快。

    2)Nginx在通过“Kill -HUP <pid>”命令重新加载配置文件时,可能会导致内存泄露。

详细配置方法:

1.增加一个方法

    perl_set $url '

        sub {

                my $r = shift;

                my $re = lc($r->uri);

                return $re;

        }

    ';

2.增加一个判断条件

        if ($uri ~ [A-Z]){

                rewrite ^(.*)$ $url last;

        }

说明:

    Perl需要Perl 5.6.1以上版本支持

整个配置文件如下:

-----------------------------------------------------------------------

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;

    tcp_nopush     on;

    #gzip  on;

    perl_set $url '

        sub {

                my $r = shift;

                my $re = lc($r->uri);

                return $re;

        }

    ';

    server {

        listen       80;

        server_name  localhost;

        if ($uri ~ [A-Z]){

                rewrite ^(.*)$ $url last;

        }

        location / {

            root   html;

            index  index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

        include       xx.cn/xx.conf;

    }

}