全球应用加速 操作步骤(通过 HTTP 请求头获取客户端真实 IP 支持 HTTP/HTTPS 协议 )

控制台操作步骤:登录 腾讯云 GAAP 控制台 > 加速通道(监听器配置) > 新增 HTTP/HTTPS 监听器管理 > 按照指引完成监听器、通道创建。

相关产品
全球应用加速 产品页,含版本规格、价格与购买入口。

注意:若你在后端适配过程中遇到无法解决的问题,可通过 工单联系 我们。

一、步骤二:后端服务适配

以下对常见的应用服务器 X-Forwarded-For 配置方案进行举例介绍:

·IIS 7 配置方案

·Apache 配置方案

·Nginx 配置方案

二、IIS 7 配置方案

1. 下载与安装插件 F5XForwardedFor 模块,根据自己的服务器操作系统版本将 x86\\Release 或者 x64\\Release 目录下的 F5XFFHttpModule.dll和F5XFFHttpModule.ini 拷贝到某个目录,这里假设为 C:\\F5XForwardedFor,确保 IIS 进程对该目录有读取权限。

2. 选择 IIS 服务器,双击模块功能。

3. 单击配置本机模块。

4. 在弹出框中单击注册。

5. 添加下载的 DLL 文件:

6. 添加完成后,勾选并单击确定。

7. 在 IIS 服务器的 “ISAPI 和 CGI 限制”中,添加如上两个 DLL ,并将限制设置为允许。

8. 重启 IIS 服务器,等待配置生效。

三、Apache 配置方案

1. 安装 Apache 第三方模块“mod_rpaf”,需执行如下命令:

wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gztar zxvf mod_rpaf-0.6.tar.gzcd mod_rpaf-0.6/usr/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

2. 修改 Apache 配置 /etc/httpd/conf/httpd.conf,需在最末尾添加:

LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname OnRPAFproxy_ips IP地址 //IP 地址为通道的转发IP
RPAFheader X-Forwarded-For

3. 添加完成后,重启 Apache。

/usr/sbin/apachectl restart

四、Nginx 配置方案

1. 当 Nginx 作为服务器时,获取客户端真实 IP,需使用 http_realip_module 模块,默认安装的 Nginx 是没有编译 http_realip_module 模块的,需要重新编译 Nginx,在configure 增加 –with-http_realip_module 选项, 确保 http_realip_module 模块编译进 nginx 中 。编译代码如下:

wget http://nginx.org/download/nginx-1.14.0.tar.gz tar zxvf nginx-1.14.0.tar.gz cd nginx-1.14.0./configure –user=www –group=www –with-http_stub_status_module –without-http-cache –with-http_ssl_module –with-http_realip_modulemakemake install

2. 修改 nginx.conf。

vi /etc/nginx/nginx.conf修改如下红色部分:fastcgi connect_timeout 300;fastcgi send_timeout 300;fastcgi read_timeout 300;fastcgi buffer_size 64k;fastcgi buffers 4 64k;fastcgi busy_buffers_size 128k;fastcgi temp_file_write_size 128k;set_real_ip_from IP地址; //IP 地址为通道转发IPreal_ip_header X-Forwarded-For;

3. 重启 Nginx。

service nginx restart

赞 (0)
上一篇 4天前
下一篇 4天前