如何在 Ubuntu Bionic 上安裝並啟用 ngx_http_limit_req_module nginx 模組

如何在 Ubuntu Bionic 上安裝並啟用 ngx_http_limit_req_module nginx 模組

我需要ngx_http_limit_req_module在 Ubuntu Bionic 上安裝 nginx。

我確實到處都能找到配置範例,但我沒有找到如何安裝或在哪裡將其作為預建模組獲取。如果我查看 gitlab 上的原始程式碼,我確實會在目錄中找到它modules/,但如果我運行nginx -V它,它就不在那裡。我還使用 nginx-stable ( ) 中給定的存儲庫https://nginx.org/packages/ubuntu/ bionic nginx,但我更喜歡預設仿生存儲庫中的 nginx 包。

我對 nginx 生態系統還很陌生,因此非常感謝您的幫助。

或者它是否已經編譯完畢並且對每個人(除了我)來說都很明顯,以至於在執行時沒有顯示nginx -V

先非常感謝:)

答案1

我現在已經嘗試過了,它開箱即用。至少使用 Ubuntu Bionic 儲存庫中的普通 nginx 套件(不是 nginx-full 或 nginx-extras...也應該可以工作)。這是nginx版本1.14.0

的輸出nginx -V

nginx version: nginx/1.14.0 (Ubuntu)
built with OpenSSL 1.1.1  11 Sep 2018
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 
-fdebug-prefix-map=/build/nginx-GkiujU/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_geoip_module=dynamic 
--with-http_gunzip_module 
--with-http_gzip_static_module 
--with-http_image_filter_module=dynamic 
--with-http_sub_module 
--with-http_xslt_module=dynamic 
--with-stream=dynamic 
--with-stream_ssl_module 
--with-mail=dynamic 
--with-mail_ssl_module

所以不是 的標誌,而且模組目錄中ngx_http_limit_req_module也沒有文件,但它正在工作。.so所以它認為它在某種程度上是 nginx 的核心。

例如,您可以ngx_http_geoip_module.c在 nginx 原始碼的模組目錄中找到(Github 中的鏡像:https://github.com/nginx/nginx/tree/master/src/http/modules),您需要像上面那樣指定。但是在同一目錄中也有該ngx_http_limit_req_module.c模組,而且您不需要指定該模組...因此完全不清楚在配置 nginx 時需要指定哪個模組。

也許這會幫助人們節省研究時間。

乾杯!

相關內容