首页 > 解决方案 > 如何包含“auth_request”模块 nginx?

问题描述

由于某种原因,找不到“auth_request”指令。我使用该heroku-buildpack-nginx更改只是为了将 包含--with-http_auth_request_modulebuild_nginx脚本中。

nginx: [emerg] unknown directive "auth_request" in ./config/nginx.conf

我的 nginx.conf:

daemon off;
# Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;

events {
    use epoll;
    accept_mutex on;
    worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %>;
}

http {
    gzip on;
    gzip_comp_level 2;
    gzip_min_length 512;

    server_tokens off;

    log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
    access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met;
    error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>;

    include mime.types;
    default_type application/octet-stream;
    sendfile on;

    # Must read the body in 5 seconds.
    client_body_timeout 5;

    upstream app_server {
        server unix:/tmp/nginx.socket fail_timeout=0;
    }

    server {
        listen <%= ENV["PORT"] %>;
        server_name _;
        keepalive_timeout 5;


        location / {
                auth_request /_oauth2_token_introspection;
                proxy_pass https://my-backend;
            }

        location = /_oauth2_token_introspection {
                internal;
                proxy_method      GET;
                proxy_set_header  Authorization "Bearer $token";
                proxy_set_header  Content-Type "application/json";
                proxy_pass        https://{myIDP};
            }
        }
}

我已将模型添加到 ./configure --with-http_auth_request_module

# This will build `nginx`
(
cd nginx-${NGINX_VERSION}
./configure \
--with-pcre=pcre-${PCRE_VERSION} \
--with-zlib=zlib-${ZLIB_VERSION} \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_auth_request_module \
--prefix=/tmp/nginx \
--add-module=${temp_dir}/nginx-${NGINX_VERSION}/headers-more-nginx-module-${HEADERS_MORE_VERSION} \
--add-module=${temp_dir}/nginx-${NGINX_VERSION}/nginx-uuid4-module-${UUID4_VERSION}
make install
)

使用 NGINX_VERSION-1.18.0。你能帮我理解为什么找不到这个模块吗?

标签: rubynginxherokubuildpack

解决方案


推荐阅读