프론트 엔 드 Nginx, 백 엔 드 아파 치가 사용자 의 실제 IP 주 소 를 가 져 옵 니 다.
Nginx 설정 은 다음 과 같 습 니 다.
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;
}
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;
실제 IP 주소 가 져 오기 Apache 모듈 2 개: modrpaf: 아파 치 - 2.2 지원;Apache - 2.4 는 지원 하지 않 습 니 다.인터넷 강좌 많은 modremoteip: Apache - 2.4 자체 모듈;아파 치 - 2.2 지원;추천 하 다.
Apache-2.2.25 mod_rpaf 모듈
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
아파 치 설정 추가
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
비고: RPAFproxyips 뒤에 프 록 시 서버 의 ip 주 소 를 추가 하고 몇 개의 테스트 를 작성 합 니 다.
# /usr/local/apache/bin/apachectl -t
# /usr/local/apache/bin/apachectl restart
#
mod_remoteip 아파 치 - 2.2 아래 mod 설정remoteip 은 다음 과 같 습 니 다: 설치
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
프로필 수정:
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
테스트:
# /usr/local/apache/bin/apachectl -t
# /usr/local/apache/bin/apachectl restart
#
아파 치 - 2.4 설정 modremoteip 위 (자체 mod remoteip 모듈 은 설치 할 필요 가 없습니다) 를 제외 하고 로그 형식 도 수정 해 야 합 니 다.
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
로그 형식 에% a 추가
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.