nginx 图片处理、权限校验配置

nginx 图片处理配置

    server {
        listen       8111;
        server_name  localhost;
        #charset koi8-r;
        access_log  /var/log/nginx/log/host.access.log  main;
        error_log  /var/log/nginx/log/error.log info;
        lua_code_cache off;
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }


    location ^~ /video/upload/ {
        root    /staticData;
    }
    location ~* ^/aa/{
            default_type 'text/plain';
            access_by_lua 'ngx.say("aaaa2")


            local res = ngx.location.capture("/proxy/http/1.1.1.1/80/Architank/us/user/checkUserLogin.do", {
                method = ngx.HTTP_POST,
                body = body,
                args = {hello = "world"}
            })


            #local cjson = require "cjson"
            ##local value=cjson.new().decode(res.body)
            #ngx.say("value","=",value)
            for key,val in pairs(res) do
                if type(val) == "table" then
                    ngx.say(key,"=>",table.concat(val,","))
                else
                    ngx.say(key,"=>",val)
                end
            end';
           # root /staticData;
        }
    location ~* ^/auth/deny/{
          #  default_type 'text/plain';
          #access_by_lua '
           # return ngx.exit(ngx.OK)
            #ngx.exit(ngx.HTTP_FORBIDDEN)
          # ';
          #rewrite ^/auth(.*)$ $1 last;
          rewrite_by_lua '
            local passArgs = ngx.req.get_uri_args()
            --ngx.log(ngx.INFO,"passArgs:",passArgs)
            local res = ngx.location.capture("/proxy/http/1.1.1.1/80/Architank/up/upload/checkFileAccessToken.do", {
                method = ngx.HTTP_POST,
                body = body,
                args = passArgs
            })
            local cjson = require "cjson"
            local value = cjson.new().decode(res.body)
            ngx.log(ngx.INFO,"value:", value.success)
            if (value.success) then


                local uri = ngx.re.sub(ngx.var.uri, "^/auth(.*)$", "$1", "o")
                ngx.log(ngx.INFO, "uri:",uri)
                ngx.req.set_uri(uri,true)
            else
                ngx.exit(ngx.HTTP_FORBIDDEN)

            end
           ';
    }
    location ^~ /deny/resume/ {
        internal;
        root    /staticData;
    }
    location ^~ /deny/ {
        root    /staticData;
    }
    location /proxy/ {


        internal;
        rewrite ^/proxy/(http?)/([^/]+)/(\d+)/(.*)     /$4 break;
        #proxy_pass http://1.1.1.1/EmployeeLeasing/us/user/checkUserLogin.do;
        #echo "$1://$2:$3";
        proxy_pass      $1://$2:$3;
    }
    location ^~ /image/upload/ {
        root    /staticData;
    }

猜你喜欢

转载自blog.csdn.net/gamezouni/article/details/78195859