我如何才能知道 nginx 是否真的包含基本身份验证?
我在模块列表中看不到它。
这是模块: http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html
nginx 版本:
root@ip-172-31-36-204:/var/www# nginx -v
nginx version: nginx/1.14.0 (Ubuntu)
Ubuntu 版本:
root@ip-172-31-36-204:/var/www# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
nginx 模块:
root@ip-172-31-36-204:/var/www# nginx -V
nginx version: nginx/1.14.0 (Ubuntu)
built with OpenSSL 1.1.1 11 Sep 2018 (running with OpenSSL 1.1.0g 2 Nov 2017)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-pTuC1b/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-headers-more-filter --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-auth-pam --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-cache-purge --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-dav-ext --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-ndk --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-echo --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-fancyindex --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/nchan --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-lua --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/rtmp --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-uploadprogress --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-upstream-fair --add-dynamic-module=/build/nginx-pTuC1b/nginx-1.14.0/debian/modules/http-subs-filter
nginx 模块(格式化):
root@ip-172-31-36-204:/var/www# nginx -V 2>&1 | tr -- - '\n' | grep module
modules
path=/usr/lib/nginx/modules
http_ssl_module
http_stub_status_module
http_realip_module
http_auth_request_module
http_v2_module
http_dav_module
http_slice_module
http_addition_module
http_flv_module
http_geoip_module=dynamic
http_gunzip_module
http_gzip_static_module
http_image_filter_module=dynamic
http_mp4_module
http_perl_module=dynamic
http_random_index_module
http_secure_link_module
http_sub_module
http_xslt_module=dynamic
mail_ssl_module
stream_ssl_module
stream_ssl_preread_module
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/nchan
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/rtmp
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
module=/build/nginx
1.14.0/debian/modules/http
root@ip-172-31-36-204:/var/www#
答案1
您自己发布了解决方案。就是这样。
如果您不能使用http_auth_request_module
,那么您有 2 个选项(我可以看到):
- 从源代码编译 nginx 并包含模块
- 只需编译模块并放入
/usr/lib/nginx/modules
即可获得源代码直接从 nginx-Repo或者Github 镜像