如何在Nginx中设置Realip模块

前端之家收集整理的这篇文章主要介绍了如何在Nginx中设置Realip模块 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想在Nginx和Cloudflare中使用http_realip_module. Nginx -V返回

built with OpenSSL 1.1.0d  26 Jan 2017 (running with OpenSSL 1.1.0e  16 Feb 2017)  
TLS SNI support enabled  
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/Nginx-F3HeH5/Nginx-1.10.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,now' --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-ipv6 --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 --add-dynamic-module=/build/Nginx-F3HeH5/Nginx-1.10.3/debian/modules/Nginx-auth-pam --add-dynamic-module=/build/Nginx-F3HeH5/Nginx-1.10.3/debian/modules/Nginx-dav-ext-module --add-dynamic-module=/build/Nginx-F3HeH5/Nginx-1.10.3/debian/modules/Nginx-echo --add-dynamic-module=/build/Nginx-F3HeH5/Nginx-1.10.3/debian/modules/Nginx-upstream-fair --add-dynamic-module=/build/Nginx-F3HeH5/Nginx-1.10.3/debian/modules/ngx_http_substitutions_filter_module

如您所见,这里有–with-http_realip_module.
/ etc / Nginx / modules-available为空,/ etc / nignx / modules-enabled返回

razem 24K
drwxr-xr-x 2 root root 4,0K kwi 23 15:58 ./
drwxr-xr-x 8 root root 4,0K kwi 23 19:53 ../
lrwxrwxrwx 1 root root   57 kwi 23 15:58 50-mod-http-auth-pam.conf -> /usr/share/Nginx/modules-available/mod-http-auth-pam.conf
lrwxrwxrwx 1 root root   56 kwi 23 15:58 50-mod-http-dav-ext.conf -> /usr/share/Nginx/modules-available/mod-http-dav-ext.conf
lrwxrwxrwx 1 root root   53 kwi 23 15:58 50-mod-http-echo.conf -> /usr/share/Nginx/modules-available/mod-http-echo.conf
lrwxrwxrwx 1 root root   54 kwi 23 15:58 50-mod-http-geoip.conf -> /usr/share/Nginx/modules-available/mod-http-geoip.conf
lrwxrwxrwx 1 root root   61 kwi 23 15:58 50-mod-http-image-filter.conf -> /usr/share/Nginx/modules-available/mod-http-image-filter.conf
lrwxrwxrwx 1 root root   60 kwi 23 15:58 50-mod-http-subs-filter.conf -> /usr/share/Nginx/modules-available/mod-http-subs-filter.conf
lrwxrwxrwx 1 root root   62 kwi 23 15:58 50-mod-http-upstream-fair.conf -> /usr/share/Nginx/modules-available/mod-http-upstream-fair.conf
lrwxrwxrwx 1 root root   60 kwi 23 15:58 50-mod-http-xslt-filter.conf -> /usr/share/Nginx/modules-available/mod-http-xslt-filter.conf
lrwxrwxrwx 1 root root   48 kwi 23 15:58 50-mod-mail.conf -> /usr/share/Nginx/modules-available/mod-mail.conf
lrwxrwxrwx 1 root root   50 kwi 23 15:58 50-mod-stream.conf -> /usr/share/Nginx/modules-available/mod-stream.conf  

我有Cloudflare right there的配置,但我不知道将其放在哪里.我必须创建配置吗?在哪里,我该如何命名?

最佳答案
您必须将其粘贴到/etc/Nginx/Nginx.conf中,然后使用sudo服务Nginx reload重新加载.
请记住首先使用Nginx -t测试配置.
原文链接:https://www.f2er.com/nginx/532337.html

猜你在找的Nginx相关文章