国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Nginx ngx_http_auth_request_module模塊鑒權(quán)

這篇具有很好參考價(jià)值的文章主要介紹了Nginx ngx_http_auth_request_module模塊鑒權(quán)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

ngx_http_auth_request_module是什么?

ngx_http_auth_request_module模塊 實(shí)現(xiàn)了基于一子請(qǐng)求的結(jié)果的客戶端的授權(quán)。如果子請(qǐng)求返回2xx響應(yīng)碼,則允許訪問(wèn)。如果它返回401或403,則訪問(wèn)被拒絕并顯示相應(yīng)的錯(cuò)誤代碼。子請(qǐng)求返回的任何其他響應(yīng)代碼都被認(rèn)為是錯(cuò)誤的。
auth_request使用的也是subrequest進(jìn)行子請(qǐng)求。

ngx_http_auth_request_module模塊用途

當(dāng)我們?cè)L問(wèn)一個(gè)資源需要進(jìn)行鑒權(quán)時(shí),可以使用Nginxhttp_auth_request_module模塊進(jìn)行處理

ngx_http_auth_request_module使用

nginx配置文件

server {
        listen       8082;
        server_name  localhost;

        location /private {
            auth_request /auth;
            # 鑒權(quán)通過(guò)后的處理方式
            proxy_pass http://127.0.0.1:8002/auth/success;
        }

        location = /auth {
            # 鑒權(quán)服務(wù)器的地址
            proxy_pass http://127.0.0.1:8002/auth/token;
            proxy_pass_request_body off;
            proxy_set_header Content-Length "";
            proxy_set_header X-Original-URI $request_uri;
         }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
}

java 代碼

package com.task.controller;

import cn.hutool.http.server.HttpServerRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wuzhenyong
 * ClassName:NginxAuthRequestController.java
 * date:2022-11-23 09:38
 * Description: 認(rèn)證服務(wù)器
 */
@RestController
@RequestMapping("/auth")
public class NginxAuthRequestController {
    @GetMapping("/token")
    public Map<String, Object> token() {
        System.out.println("請(qǐng)求認(rèn)證服務(wù)器接口" + LocalDateTime.now());
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("code", 200);
        result.put("msg", "成功");
        return result;
        // throw new RuntimeException("認(rèn)證失敗");
    }
    @GetMapping("/success")
    public Map<String, Object> success() {
        System.out.println("認(rèn)證成功" + LocalDateTime.now());
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("code", 200);
        result.put("msg", "成功");
        return result;
    }
}

測(cè)試模擬認(rèn)證成功

瀏覽器訪問(wèn)地址:http://localhost:8082/private

nginx auth_request,中間件服務(wù),nginx,http,服務(wù)器

控制臺(tái)打?。?br>nginx auth_request,中間件服務(wù),nginx,http,服務(wù)器

模擬認(rèn)證失敗,拋出異常

代碼變動(dòng):
nginx auth_request,中間件服務(wù),nginx,http,服務(wù)器

重啟項(xiàng)目訪問(wèn)測(cè)試:
nginx auth_request,中間件服務(wù),nginx,http,服務(wù)器
返回的是nginx的錯(cuò)誤頁(yè)面哦,也可以自定義處理文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-584773.html

到了這里,關(guān)于Nginx ngx_http_auth_request_module模塊鑒權(quán)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • nginx配置SSL數(shù)字證書(shū)、報(bào)錯(cuò)nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in

    nginx配置SSL數(shù)字證書(shū)、報(bào)錯(cuò)nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in

    nginx一般默認(rèn)安裝目錄是 /usr/local/nginx,請(qǐng)按自己實(shí)際安裝目錄操作 名稱 命令 查看版本 /usr/local/nginx/sbin/nginx -v 啟動(dòng)服務(wù) /usr/local/nginx/sbin/nginx 重啟服務(wù) /usr/local/nginx/sbin/nginx-s restart 停止服務(wù) /usr/local/nginx/sbin/nginx -s stop 是否啟動(dòng) ps -ef | grep nginx 強(qiáng)制結(jié)束 kill 進(jìn)程ID (如:kil

    2024年02月15日
    瀏覽(29)
  • Nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf

    ??出現(xiàn)上面標(biāo)題中的問(wèn)題是因?yàn)槲耶?dāng)初在安裝Nginx的時(shí)候沒(méi)有安裝SSL模塊,但是現(xiàn)在我在Nginx配置文件(nginx.cnf)中配置了SSL的相關(guān)配置信息。當(dāng)我再次啟動(dòng)Nginx的時(shí)候就提示我 nginx: [emerg] the \\\"ssl\\\" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:111 了。下面我將我的解

    2024年02月07日
    瀏覽(23)
  • [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:35

    這個(gè)錯(cuò)誤提示表明在Nginx配置文件(通常是nginx.conf)中使用了SSL(Secure Sockets Layer)相關(guān)的配置,但是Nginx沒(méi)有加載相應(yīng)的SSL模塊。 1.檢查Nginx是否編譯了SSL模塊: /usr/local/nginx/sbin/nginx -V 21 | grep --color=auto ssl /usr/local/nginx/sbin/nginx:安裝nginx的絕對(duì)路徑 輸出以下結(jié)果 則為安裝已

    2024年03月16日
    瀏覽(29)
  • ngx_http_request_s

    ngx_http_request_s

    ngx_http_headers_out_t? ngx_list_t

    2024年02月06日
    瀏覽(13)
  • 解決Nginx啟動(dòng)報(bào)錯(cuò)“nginx: [emerg] unknown directive “ngx_fastdfs_module“ in /xxx/nginx/conf/nginx.conf:43“

    解決Nginx啟動(dòng)報(bào)錯(cuò)“nginx: [emerg] unknown directive “ngx_fastdfs_module“ in /xxx/nginx/conf/nginx.conf:43“

    centos7操作系統(tǒng),nginx被人安裝過(guò)多次,重啟服務(wù)器,發(fā)現(xiàn)nignx未設(shè)置開(kāi)機(jī)自啟,啟動(dòng)報(bào)錯(cuò)nginx: [emerg] unknown directive “ngx_fastdfs_module” in /usr/local/nginx/conf/nginx.conf:43 1、嘗試啟動(dòng),查看報(bào)錯(cuò)日志 上述命令如果報(bào)nginx.service找不到: Failed to start nginx.service: Unit not found. ,則進(jìn)入ngi

    2024年02月07日
    瀏覽(65)
  • /usr/lib64/nginx/modules/ngx_stream_module.so: undefined symbol: SSL_CTX_set_options

    概述 系統(tǒng)是centos 7 問(wèn)題是加入stream出現(xiàn)問(wèn)題。 加入stream模塊 重新編譯 nginx.conf 第一行 ./nginx -t 如果出現(xiàn)以下異常 則直接拷貝源碼objs中的文件

    2024年02月13日
    瀏覽(19)
  • nginx http rewrite module 詳解

    大家好,我是 17。 今天和大家聊聊 nginx http rewrite module 。 簡(jiǎn)單來(lái)說(shuō), ngx_http_rewrite_module module 用正則匹配請(qǐng)求,改寫(xiě)請(qǐng)求,然后做跳轉(zhuǎn)??梢允莾?nèi)部跳轉(zhuǎn),也可以是外部跳轉(zhuǎn)。 學(xué)習(xí)這個(gè)模塊的時(shí)候,把 rewrite_log 打開(kāi),可以在 error log 里查看跳轉(zhuǎn)信息 注意 notice 是必須的 直接

    2023年04月08日
    瀏覽(17)
  • Linux安裝Nginx并集成nginx-http-flv-module

    下載 Nginx:?https://nginx.org/download nginx-http-flv-module:?https://github.com/winshining/nginx-http-flv-module nginx可自行選擇版本下載 ,nginx-http-flv-module可以通過(guò)git下載 解壓安裝 查找nginx安裝目錄 修改成如下配置 啟動(dòng) cd ../sbin ./nginx

    2024年02月15日
    瀏覽(25)
  • Nginx + RTMP + nginx-http-flv-module 環(huán)境搭建(CentOS 7)

    Nginx + RTMP + nginx-http-flv-module 環(huán)境搭建(CentOS 7)

    ??Nginx + RTMP + nginx-http-flv-module 環(huán)境搭建(CentOS 7) ☆* o(≧▽≦)o *☆嗨~我是IT·陳寒?? ?博客主頁(yè):IT·陳寒的博客 ??該系列文章專欄:Java學(xué)習(xí)路線 ??其他專欄:Java學(xué)習(xí)路線 Java面試技巧 Java實(shí)戰(zhàn)項(xiàng)目 AIGC人工智能 數(shù)據(jù)結(jié)構(gòu)學(xué)習(xí) ??文章作者技術(shù)和水平有限,如果文中出現(xiàn)

    2024年02月05日
    瀏覽(49)
  • python Requests添加Auth和Cert

    python Requests添加Auth和Cert

    最近通過(guò)postman發(fā)起另外一個(gè)項(xiàng)目的請(qǐng)求,鑒權(quán)較為復(fù)雜,首先需要設(shè)置cert,postman中設(shè)置如下: 需要設(shè)置basic auth的參數(shù) 然后將接口返回的token放入auth的bearer token中。 實(shí)際使用時(shí)發(fā)現(xiàn)使用postman的數(shù)據(jù)驅(qū)動(dòng)功能較為麻煩,而且不利于對(duì)測(cè)試結(jié)果日志采集,于是通過(guò)requests實(shí)現(xiàn)該

    2024年02月12日
    瀏覽(13)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包