从 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 用得比较多的同志咋回事