خوب کسی جواب نداد ۸ ساعت قفل کردم روش تا فهمیدم.
ابتدا باید کامپایل کنید.
Manual Nginx compilation (Page 1) — Help and Support — Linux Server Management | Web Hosting Support | Outsourced Spport | Enterprise Cluster Administration | Software Development by Syslint Technologies
البته باید ورژن ngnix را از سایت رسمی دانلود کنید و در داخل پوشه
/usr/local/nginx extract کنید و سپس فرامینی که نوشتم را اجرا کنید.
کد:# ./configure --prefix=/usr/local/nginx --with-http_realip_module # make # make install # cp -f /etc/cpnginx/nginx.cont.template /usr/local/nginx/conf/nginx.conf # touch /usr/local/nginx/conf/vhost.conf # /script/rebuildnginxvhost # /etc/init.d/nginx restart
از این ماژول استفاده و نصب کنید
HttpRealIpModule
HttpRealIpModule
سپس پس از نصب و ریست کردن nginx.
کد:nano /usr/local/nginx/conf/nginx.conf# cPanel Nginx Master configuration
user nobody;
error_log logs/error.log;
#Number of worker you need
worker_processes 1;
# How many connections a worker can handle maximum.
events {
worker_connections 50000;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server_names_hash_max_size 10000;
server_names_hash_bucket_size 1024;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
ignore_invalid_headers on;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
set_real_ip_from ***.***.***.***;
real_ip_header X-Real-IP;
include "/usr/local/nginx/conf/vhost.conf";
include "/etc/cpnginx/cpanel*****.conf";
}
حالا اون ستارهها چی؟ یعنی اگر از Cloudflare یا از load balancer استفاده میکنید که اصطلاحا ۲ یا بیشتر P-r-o-xy ip reverse دارید. که میخواهید به ip واقعی تبدیل شود و ip بینندههای سایت شما واقعی باشد نه ip cloud یا ip سایت.
به جای اون ستاره که آیپی هست باید آیپی پراکسی function reverse() { [native code] } یا کلودفلر
INFO:
set_real_ip_from *****_1_IP;
real_ip_header X-Forwarded-For;
X-Forwarded-For: client1, *****_1_IP
$remote_addr = client1 (which is expected)
open port 8888
پورت ۸۸۸۸ را در فایروال سخت افزاری و نرمافزاری و هر چی هست باز کنید
You may also edit /usr/local/apache/conf/mod_rpaf.conf with the followingset_real_ip_from | real_ip_header
RPAFheader X-Real-IP
RPAFheader X-Forwarded-For
شما باید rpaf را edit کنید و مانند مثال ذخیره کنید.
یا اینکه در بالا nginx.conf از کد زیر استفاده کنید آن ۲ خطی ke قرمز کردم.
real_ip_header X-Forwarded-For;
خوب بعد ریست کنید nginx را و مشاهده میکنید که آیپیهای سایت یا بازدید کنندها واقعی هستند و دیگر آیپی cloud و یا سایت اصلی نیست.