V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
dltsgl
V2EX  ›  问与答

nginx: [emerg] unknown "valid_referers" variable

  •  
  •   dltsgl · 79 天前 · 82 次点击
    这是一个创建于 79 天前的主题,其中的信息可能已经有所发展或是发生改变。

    从 dockerhub 下载了 nginx-1.24.0 版本的镜像,启动后,把自己的 nginx 配置复制进去生成新镜像,然后再启动,报错,就是标题里的错误 查了一下,是需要 http_referer_module ,又查到这个是 nginx 内置的,默认启用的;后来又下了 debian-buseye 镜像,自己下载 nginx 复制进去编译安装,编译安装后用同样的配置,还是一样的报错,编译参数如下

    ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_referer_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.24.0/debian/debuild-base/nginx-1.24.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' 
    

    如果编译时添加--with-http_referer_module ,就会报 invalid option "--with-http_referer_module"

    nginx 的配置如下

    server {
        listen       443 ssl;
    
    	server_tokens off;
        server_name xxx;
        set $flag 0;
        if ($host = "xxx") {
            set $flag 1;
        }
        if ($flag = 0) {
            return 403;
        }
    
        valid_referers server_name;
        if ($valid_referers) {
            return 403;
        }
    
        if ($request_method = PUT) {
            return 403;
        }
    
        if ($request_method = DELETE) {
            return 403;
        }
    
        server_name_in_redirect off;
        port_in_redirect off;
    
        ssl_certificate      xxx;
        ssl_certificate_key  xxx;
    
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
    
        ssl_verify_client off;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
    }
    

    网上也没搜到,技穷了,请教一下 nginx 用得比较多的同志咋回事

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1026 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:58 · PVG 03:58 · LAX 12:58 · JFK 15:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.