|
Son zamanlarda genel olarakApache-2.2 veApache-2.4 eklemek için "LNMP tek tıklama kurulum paketi",NginxÖn uç olarak Apache, yalnızca Nginx ön yüzünün IP adresini (127.0.0.1) elde edebilir, ancak kullanıcının gerçek IP adresini elde edemez. Nginx şu şekilde yapılandırılmıştır: - location / {
- try_files $uri @apache;
- }
- location @apache {
- internal;
- proxy_pass http://127.0.0.1:8080;
- include proxy.conf;
- }
- location ~ .*\.(php|php5)?$ {
- proxy_pass http://127.0.0.1:8080;
- include proxy.conf;
- }
Kopya kodu- proxy_connect_timeout 300s;
- proxy_send_timeout 900;
- proxy_read_timeout 900;
- proxy_buffer_size 32k;
- proxy_buffers 4 64k;
- proxy_busy_buffers_size 128k;
- proxy_redirect off;
- proxy_hide_header Vary;
- proxy_set_header Accept-Encoding '';
- proxy_set_header Referer $http_referer;
- proxy_set_header Cookie $http_cookie;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Kopya koduApache'de gerçek IP adresi almak için 2 modül vardır:
mod_rpaf: Apache-2.2 destekleniyor; Apache-2.4 desteklenmiyor. Çevrimiçi birçok eğitim programı var
mod_remoteip: Apache-2.4 modüllerle birlikte gelir; Apache-2.2 desteği;Öner Apache-2.2.25
mod_rpaf modülü - wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
- tar -xzvf mod_rpaf-0.6.tar.gz
- cd mod_rpaf-0.6/
- /usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.slo mod_rpaf-2.0.c
Kopya koduApache yapılandırmasını ekle - vi /usr/local/apache/conf/httpd.conf
- Include conf/extra/httpd-rpaf.conf
- vi /usr/local/apache/conf/extra/httpd-rpaf.conf
- LoadModule rpaf_module modules/mod_rpaf-2.0.so
- RPAFenable On
- RPAFsethostname On
- RPAFproxy_ips 127.0.0.1 10.8.0.110 # 代理服务器的ip地址(记得做相应修改)
- RPAFheader X-Forwarded-For
Kopya koduNot: RPAFproxy_ips sonra proxy sunucunun IP adresini ekleyin ve birkaç adres ekleyin Test - # /usr/local/apache/bin/apachectl -t
- # /usr/local/apache/bin/apachectl restart
- # 看日志
Kopya kodumod_remoteip Apache-2.2 altında mod_remoteip yapılandırma şu şekildedir: Kurma - wget https://github.com/ttkzw/mod_remoteip-httpd22/raw/master/mod_remoteip.c
- /usr/local/apache/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c
Kopya koduProfili değiştirin: - vi /usr/local/apache/conf/httpd.conf
- Include conf/extra/httpd-remoteip.conf
- vi /usr/local/apache/conf/extra/httpd-remoteip.conf
- LoadModule remoteip_module modules/mod_remoteip.so
- RemoteIPHeader X-Forwarded-For
- RemoteIPInternalProxy 127.0.0.1
Kopya koduTest: - # /usr/local/apache/bin/apachectl -t
- # /usr/local/apache/bin/apachectl restart
- # 看日志
Kopya koduApache-2.4 yapılandırması mod_remoteip yukarıda belirtilenlere ek olarak (kendi mod_remoteip olan modülün kurulmasına gerek yok), günlük formatını da değiştirmeniz gerekiyor (uzun süre atılır). - LogFormat "%h %a %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
- LogFormat "%h %a %l %u %t "%r" %>s %b" common
- LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedi
Kopya kodu
%a'yı log formatına ekle
|