Nginx基於http響應狀態碼做權限控制的auth_request模塊


基於子請求收到的HTTP響應碼做訪問控制

默認並未編譯進Nginx,通過--with-http-auth-request-module啟用

location / {
            root   html;
            index  index.html index.htm;
            auth_request /auth;
        }

        location /auth {
                #return 403 "error";
                return 200 "success"
        }

實際應用中,/auth中一般通過反向代理到鑒權服務器來返回狀態碼判斷是否通過驗證
location /private/ {
      auth_request /auth;
}

location /auth {
      proxy_pass http://127.0.0.1:8080/verify;
      proxy_pass_request_body off;
      proxy_set_header Content-Length "";
      proxy_set_header X-Original-URL $request_uri;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM