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