Hướng dẫn cài đặt lấy IP thật sau Reverse Proxy trên cPanel

Giới thiệu

Hiện nay có rất nhiều website sử dụng dịch vụ Reverse Proxy, dịch vụ Cloudflare hoặc sử dụng Firewall chuyên dụng đứng trước Web server với các mục đích khác nhau, Tuy nhiên với cấu hình mặc định, Server web chỉ ghi nhận được IP truy cập tới là IP của Reverse Proxy server, Cloudflare hay IP của Firewall mà không phải IP của khách truy cập.

Có thể sử dụng mode mod_remoteip của Apache để giải quyết vấn đề này.

Quý khách có thể xem thêm tại: Apache documentation


Hướng dẫn sau đây sẽ giúp Quý khách cài đặt mod_remoteip trên Cpanel sử dụng Apache.

Bước 1: Cài đặt mod_remoteip

Để cài đặt mod_remoteip, quý khách có thể sử dụng yum thông qua SSH với câu lệnh

yum install ea-apache24-mod_remoteip

Bước 2: Tạo hoặc sửa đổi tệp cấu hình cho mod_remoteip.

vi /etc/apache2/conf.modules.d/370_mod_remoteip.conf

Trong tệp này, quý khách cần cấu hình địa chỉ của Reverse proxy hay firewall, nếu Reverse proxy hay firewall đang sử dụng mạng nội bộ, quý khách sử dụng RemoteIPInternalProxy thay vì RemoteIPTrustedProxy

Ví dụ

Reverse proxy có ip 45.122.221.201

RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 45.122.221.201


Reverse proxy có sử dụng IP Local có IP 192.168.1.100

RemoteIPHeader X-Forwarded-For 
RemoteIPInternalProxy 192.168.1.100

Nếu có IP cần bổ xung, Quý khách có thể thực hiện việc này bằng cách thêm chúng lần lượt
Ví dụ thêm IP 8.8.8.8 chẳng hạn

RemoteIPHeader X-Forwarded-For 
RemoteIPTrustedProxy 45.122.221.201 8.8.8.8

Nếu Quý khách đang sử dụng dịch vụ Reverse Proxy của vHost, có thể sử dụng file cấu hình sau

RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 103.27.60.0/22
RemoteIPTrustedProxy 103.232.120.0/22
RemoteIPTrustedProxy 2401:78C0::/32
RemoteIPTrustedProxy 45.122.220.0/22
RemoteIPTrustedProxy 103.92.28.0/22
RemoteIPTrustedProxy 2401:78C0::/32
RemoteIPTrustedProxy 103.143.142.0/23
RemoteIPTrustedProxy 2405:5440:0000::/48
RemoteIPTrustedProxy 2405:54c0:0000::/48
RemoteIPTrustedProxy 103.231.188.0/22
RemoteIPTrustedProxy 2404:54C0::/32
RemoteIPTrustedProxy 103.83.156.0/22
RemoteIPTrustedProxy 2404:55C0::/32
RemoteIPTrustedProxy 103.143.208.0/23
RemoteIPTrustedProxy 2001:df1:9780::/48
RemoteIPTrustedProxy 137.220.54.105/32
RemoteIPTrustedProxy 45.77.129.107/32
RemoteIPTrustedProxy 149.28.180.100/32
RemoteIPTrustedProxy 158.247.221.251/32
RemoteIPTrustedProxy 217.69.10.197/32
RemoteIPTrustedProxy 192.248.164.234/32
RemoteIPTrustedProxy 45.63.117.217/32
RemoteIPTrustedProxy 139.84.137.89/32
RemoteIPTrustedProxy 139.84.235.211/32
RemoteIPTrustedProxy 144.202.98.211/32

Nếu Quý khách có bất kỳ câu hỏi hoặc nhận xét nào, vui lòng để lại bình luận bên dưới.

Xem thêm nhiều bài hướng dẫn hơn tại: https://howto.nsupport.asia
Tham khảo thêm nhiều dịch vụ tại: https://vhost.vn

Was this article helpful?

Related Articles

Leave A Comment?