zoukankan      html  css  js  c++  java
  • nginx 根据端口不同实现负载均衡

    upstream www.abc.com {
    server www.mynginx.com:91;
    server www.mynginx.com:92;
    }
    server {
    listen 80;
    server_name www.mynginx.com;
    location / {
    root D:/www/mynginx;
    index index.html index.htm index.php;
    proxy_pass http://www.abc.com;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location ~ .php$ {
    root D:/www/mynginx;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }
    server {
    listen 91;
    server_name www.mynginx.com:91;
    location / {
    root D:/www/nginx01;
    index index.html index.htm index.php;

    }
    location ~ .php$ {
    root D:/www/nginx01;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }
    server {
    listen 92;
    server_name www.mynginx.com:92;
    location / {
    root D:/www/nginx02;
    index index.html index.htm index.php;
    }
    location ~ .php$ {
    root D:/www/nginx02;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }
    然后访问http://www.mynginx.com,其实是轮流访问www.mynginx.com:91,www.mynginx.com:92
     



  • 相关阅读:
    MySQL 约束
    MySQL 基础
    LeetCode-Backtracking-Easy 回溯算法
    cookie session区别
    mac环境下支持PHP调试工具xdebug,phpstorm监听
    dede修改移动文档的js
    ajax是怎么发请求的和浏览器发的请求一样吗?cookie
    linux命令
    mysql里的sql函数
    nginx启动
  • 原文地址:https://www.cnblogs.com/lixiuyuan999/p/6399219.html
Copyright © 2011-2022 走看看