nginx对静态资源或者路径鉴权的处理方案(Linux和windows)

nginx官网下载最新稳定版,

我这里下载:nginx-1.16.1.tar.gz

下载pcre,解压备用

我的nginx编译参数:

./configure --prefix=/home/xxxx/software/nginx  --with-pcre=/home/xxxx/software/pcre-8.43  --with-http_auth_request_module

编译后,nginx的配置文件中新增如下location。因为只需要验证头部和请求路径,所以将没用的body舍弃。

/auth 返回200时,会继续往下走,如果/auth返回其他标识,则直接返回。

location ^~ /uploadfiles/members/ {
                limit_except GET POST {deny  all; } 
                auth_request /auth;
                
                root  /release_baike/statics/;
}

location = /auth {
            internal;
            proxy_set_header Host $host;
            proxy_pass_request_body off;
            proxy_set_header Content-Length "";
            proxy_pass http://localhost:9080/auth;
            proxy_set_header X-Original-URI $request_uri;
 }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章