当前位置:  操作系统/服务器>linux
本页文章导读:
    ▪nginx 负载均衡的简单配置方法       代码如下:http      {        upstream www.test2.com {                  server 10.1.165.36:80  weight = 3;                  server 10.249.198.235;               server 10.1.168.1  down;   .........
    ▪nginx提示502 页面的解决方法       例如: 代码如下:    http      {      ......      fastcgi_connect_timeout 300;      fastcgi_send_timeout 300;      fastcgi_read_timeout 300;      ......      }    也有可能是PHP代码不正确,比如SVN冲.........
    ▪让iis记录nginx反向代理的真实ip       一、设置X-Forwarded-For段 nginx配置示例: 代码如下:server{   location   {      ...     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;     ...   }} 二、在iis站点上安装isapi filter 在f5.........

[1]nginx 负载均衡的简单配置方法
    来源: 互联网  发布时间: 2013-12-24

代码如下:

http 
    { 
      upstream www.test2.com { 
                server 10.1.165.36:80  weight = 3;         
        server 10.249.198.235; 
             server 10.1.168.1  down;  
             server 10.1.168.2  backup; 
            #ip_hash; 
       } 
      server 
      { 
            location / { 
                  proxy_pass        http://www.test2.com; 
                  proxy_set_header   Host             $host; 
                  proxy_set_header   X-Real-IP        $remote_addr; 
                  proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for; 
                  } 
    }

Nginx负载均衡需要添加 upstream  和在Server中添加proxy_pass

server 10.1.165.36:80  weight = 3;  代表这个服务器会有相同概率的3倍被访问
server 10.1.168.1  down;  暂时不使用
server 10.1.168.2  backup; 压力大的时候才会启动
ip_hash;通过IP地址进行hash匹配。但是会有一些弊端,比如Nginx不在最外层的话就无法获取IP等
proxy_pass http://www.test2.com  代表访问的网址


    
[2]nginx提示502 页面的解决方法
    来源: 互联网  发布时间: 2013-12-24

例如:

代码如下:

    http 
    { 
    ...... 
    fastcgi_connect_timeout 300; 
    fastcgi_send_timeout 300; 
    fastcgi_read_timeout 300; 
    ...... 
    } 
 

也有可能是PHP代码不正确,比如SVN冲突等原因。


    
[3]让iis记录nginx反向代理的真实ip
    来源: 互联网  发布时间: 2013-12-24

一、设置X-Forwarded-For段

nginx配置示例:

代码如下:
server
{
   location
   {
     ...
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
     ...
   }

二、在iis站点上安装isapi filter

在f5的开发论坛上找到的,按开发者的话说,是为了解决iis放在f5后记录不到用户ip的问题,管他前端是f5还是nginx还是squid还是haproxy,都可以用。
装完之后重启下iis即可。

https://devcentral.f5.com/weblogs/Joe/archive/2009/08/19/x_forwarded_for_log_filter_for_windows_servers.aspx

安装方法,从官方文档复制了过来的,大家看看咯。
Installation

Follow these steps to install the filter.

Download and unzip the F5XForwardedFor.zip distribution.
Copy the F5XForwardedFor.dll file from the x86\Release or x64\Release directory (depending on your platform) into a target directory on your system. Let's say C:\ISAPIFilters.
Ensure that the containing directory and the F5XForwardedFor.dll file have read permissions by the IIS process. It's easiest to just give full read access to everyone.
Open the IIS Admin utility and navigate to the web server you would like to apply it to.
For IIS6, Right click on your web server and select Properties. Then select the "ISAPI Filters" tab. From there click the "Add" button and enter "F5XForwardedFor" for the Name and the path to the file "c:\ISAPIFilters\F5XForwardedFor.dll" to the Executable field and click OK enough times to exit the property dialogs. At this point the filter should be working for you. You can go back into the property dialog to determine whether the filter is active or an error occurred.
For II7, you'll want to select your website and then double click on the "ISAPI Filters" icon that shows up in the Features View. In the Actions Pane on the right select the "Add" link and enter "F5XForwardedFor" for the name and "C:\ISAPIFilters\F5XForwardedFor.dll" for the Executable. Click OK and you are set to go.
I'd love to hear feedback on this and if there are any other feature request, I'm wide open to suggestions. The source code is included in the download distribution so if you make any changes yourself, let me know!

Good luck and happy filtering!


    
最新技术文章:
▪linux系统中的列出敏感用户的脚本代码
▪a10 config backup for aXAPI
▪一键备份gitolite服务器的Shell脚本
▪nagios 分发文件实现代码
▪阿里云云服务器Linux系统更新yum源Shell脚本
▪一个监控LINUX目录和文件变化的Shell脚本分享
▪Linux下实现SSH免密码登录和实现秘钥的管理、...
▪Shell正则表达式之grep、sed、awk实操笔记
▪3个备份系统文件并邮件发送的Shell脚本分享
▪CentOS 6.3下给PHP添加mssql扩展模块教程
▪监控网站是否可以正常打开的Shell脚本分享
▪shell脚本编程之if语句学习笔记
▪shell脚本编程之循环语句学习笔记
▪shell脚本编程之case语句学习笔记
▪Shell脚本实现的阳历转农历代码分享
▪Shell脚本实现复制文件到多台服务器的代码分...
▪Shell脚本实现批量下载网络图片代码分享
▪Shell脚本实现检测文件是否被修改过代码分享
▪Shell脚本数组用法小结
▪Shell脚本批量重命名文件后缀的3种实现
▪C语言实现的ls命令源码分享
▪Linux下查找后门程序 CentOS 查后门程序的shell脚...
▪Shell 函数参数
▪linux shell 自定义函数方法(定义、返回值、变...
▪Shell实现判断进程是否存在并重新启动脚本分...
▪Shell脚本break和continue命令简明教程
▪Shell脚本函数定义和函数参数
▪让代码整洁、过程清晰的BASH Shell编程技巧
▪shell常用重定向实例讲解
▪awk中RS、ORS、FS、OFS的区别和联系小结
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3