openresty安装lua和nginx相关

server{
    listen 80;
    server_name a.com;
    index index.php;
    root /usr/share/nginx/html;
        location / {        
        if (!-e $request_filename) {
                    rewrite  ^/(.*)$  /index.php/$1  last;
                    break;
        }
        }
                     
    location ~ \.php {
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
         include ./conf.d/fcgi.conf;
         set $real_script_name $fastcgi_script_name;
         if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
             set $real_script_name $1;
             set $path_info $2;
         }
         fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
         fastcgi_param SCRIPT_NAME $real_script_name;
         fastcgi_param PATH_INFO $path_info;
    }
   location ~* .(jpg|gif|png|js|css)$ {
    if (-f $request_filename) {
        expires 30d;
        break;
    }
}

 nginx 忽略大小写安装nginx lua模块

手动编译nginx,安装lua-nginx-module步骤

 1,环境支持

apt-get install libreadline-dev libncurses5-dev libpcre3-dev \
    libssl-dev perl make build-essential

apt-get install postgresql-9.3 postgresql-server-dev-9.3

2,下载openresty

sudo wget https://openresty.org/download/openresty-1.11.2.2.tar.gz

3,编译

sudo ./configure --prefix=/usr/local/openresty \
            --with-luajit \
            --without-http_redis2_module \
            --with-http_iconv_module \
            --with-http_postgres_module

4,配置nginx访问路径

sudo ln -s /usr/local/openresty/nginx/sbin/nginx /usr/local/sbin/nginx

5,启动 sudo nginx

    结束.

Nginx简单防盗链

静态文件匹配处改为如下
location ~ .*\.(jpg|jpeg|JPG|png|gif|icon)$ {
        valid_referers blocked www.qixing318.com qixing318.com;
        if ($invalid_referer) {
            return 404;
        }
}

 Nginx禁止访问目录

location ~* \.(txt|doc)${
    root /data/www/wwwroot/linuxtone/test;
    deny all;
}

 Nginx设置缓存

proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m
use_temp_path=off;
server {
    ...
    location / {
        proxy_cache my_cache;
        proxy_cache_revalidate on;
        proxy_cache_min_uses 3;
        proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
        proxy_cache_lock on;
        proxy_pass http://my_upstream;
    }
}
详细文档讲解
https://moonbingbing.gitbooks.io/openresty-best-practices/content/ngx/static_file.html

 

 

参考文档:

http://openresty.org/cn/installation.html

 https://moonbingbing.gitbooks.io/openresty-best-practices/content/ngx/nginx_local_pcre.html

转载于:https://www.cnblogs.com/peixiguang/p/6135133.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值