Nginx 安裝 module auth_request 失敗

2022-06-24 15:14:33 +08:00
 cnit
[root@AliYun conf.d]# nginx -V
nginx version: nginx/1.18.0
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) 
built with OpenSSL 1.1.1k  FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module👉 --with-http_auth_request_module 👈--with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

[root@AliYun conf.d]# nginx -V 2>&1 | grep -qF -- --with-http_auth_request_module && echo "Module Compiled" || echo "Not Compiled"
Module Compiled
[root@AliYun conf.d]# 


Jun 24 14:57:36 AliYun nginx[87531]: nginx: [emerg] unknown directive👉 "auth_request"👈 in /home/nginx/conf/conf.d/xxxx.conf:13
Jun 24 14:57:36 AliYun systemd[1]: nginx.service: Control process exited, code=exited status=1
Jun 24 14:57:36 AliYun systemd[1]: nginx.service: Failed with result 'exit-code'.
Jun 24 14:57:36 AliYun systemd[1]: Failed to start Nginx proxy.
server {
   listen 80;
   listen 443 ssl;
   server_name xxxx;

   underscores_in_headers on;
   include /home/nginx/ssl/ssl.conf;

   location ~ ^/(demos|sig)/ {
         auth_request /console  👈
         proxy_pass http://xxxxx$request_uri;
         proxy_set_header   Host             $host;
         proxy_set_header   X-Real-IP        $remote_addr;
         proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "Upgrade";
         proxy_set_header X-Real-IP $remote_addr;
    }
    ...

指定 configure 参数之后,进行了 make && make install 折騰一天了 大佬帮忙看看吧

1429 次点击
所在节点    NGINX
14 条回复
q1angch0u
2022-06-24 15:25:10 +08:00
你 /console 后边儿的分号呢……
1point
2022-06-24 15:29:09 +08:00
我也感觉是没有;的问题
cnit
2022-06-24 15:29:57 +08:00
@q1angch0u 刚刚加上分号试了,问题依旧
q1angch0u
2022-06-24 15:32:21 +08:00
@q1angch0u 虽然报错是找不到指令……
q1angch0u
2022-06-24 15:32:37 +08:00
@cnit 你看看你编译的和要跑的是一个 bin 吗?
cnit
2022-06-24 15:37:30 +08:00
[root@AliYun conf.d]# ps -ef|grep nginx
root 91899 1 0 15:29 ? 00:00:00 nginx: master process /home/nginx/sbin/ 👈
nobody 91900 91899 0 15:29 ? 00:00:00 nginx: worker process
nobody 91901 91899 0 15:29 ? 00:00:00 nginx: worker process
nobody 91902 91899 0 15:29 ? 00:00:00 nginx: worker process
nobody 91903 91899 0 15:29 ? 00:00:00 nginx: worker process
nobody 91904 91899 0 15:29 ? 00:00:00 nginx: cache manager process
root 92464 4155721 0 15:36 pts/0 00:00:00 grep --color=auto nginx
root 4168638 4155721 0 11:44 pts/0 00:00:00 vim nginx.conf
[root@AliYun conf.d]# nginx -V
nginx version: nginx/1.18.0
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx 👈 --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-


是这个问题吗?
cnit
2022-06-24 15:37:50 +08:00
dier
2022-06-24 15:45:15 +08:00
我觉得应该是#5 说的问题,你这两个路径下都有 nginx ,如果不是做的链接,那说明安装了两个版本。
q1angch0u
2022-06-24 15:47:46 +08:00
@cnit 你这不是一个 nginx 吧…备份替换下?
cnit
2022-06-24 15:55:58 +08:00
我备份了 /home/nginx 然后在其目录下指定了 configure 的路径为当前路径,在 make install 的时候
install: build install_perl_modules
test -d '$(DESTDIR)/home/nginx' || mkdir -p '$(DESTDIR)/home/nginx'

test -d '$(DESTDIR)/home' \
|| mkdir -p '$(DESTDIR)/home'
test ! -f '$(DESTDIR)/home/nginx/' \ 👈 这里报错了
|| mv '$(DESTDIR)/home/nginx/' \
'$(DESTDIR)/home/nginx/.old'
cp objs/nginx '$(DESTDIR)/home/nginx/'

sbin-path 指定如下:
--sbin-path=/home/nginx/

@q1angch0u
cnit
2022-06-24 15:57:27 +08:00
他为啥会给加个 $(DESTDIR) 呢
cnit
2022-06-24 15:58:14 +08:00
--prefix 是这个值
q1angch0u
2022-06-24 16:16:36 +08:00
@cnit 不用那么麻烦啊……
可以先不用移动,用`/usr/sbin/nginx -c <path_to_config> -t`看看配置文件有没有问题,如果没问题的话再`cp /home/nginx/sbin/nginx{,.bak} && cp /usr/sbin/nginx /home/nginx/sbin/nginx`
cnit
2022-06-24 16:26:44 +08:00
@q1angch0u 可以了!!! 谢谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/861941

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX