www.zyan.cc 和 blog.zyan.cc 域名均指向 Nginx 所在的服务器IP。

  用户访问http://www.zyan.cc,将其负载均衡到192.168.1.2:80、192.168.1.3:80、192.168.1.4:80、192.168.1.5:80四台服务器。

  用户访问http://blog.zyan.cc,将其负载均衡到192.168.1.7服务器的8080、8081、8082端口。

  以下为配置文件nginx.conf:

引用
user  www www;

worker_processes 10;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

#最大文件描述符
worker_rlimit_nofile 51200;

events
{
      use epoll;

      worker_connections 51200;
}

http
{
      include       conf/mime.types;
      default_type  application/octet-stream;

      keepalive_timeout 120;

      tcp_nodelay on;

      upstream  www.zyan.cc  {
              server   192.168.1.2:80;
              server   192.168.1.3:80;
              server   192.168.1.4:80;
              server   192.168.1.5:80;
      }

      upstream  blog.zyan.cc  {
              server   192.168.1.7:8080;
              server   192.168.1.7:8081;
              server   192.168.1.7:8082;
      }

      server
      {
              listen  80;
              server_name  www.zyan.cc;

              location / {
                       proxy_pass        http://www.zyan.cc;
                       proxy_set_header   Host             $host;
                       proxy_set_header   X-Real-IP        $remote_addr;
                       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
              }

              log_format  www_s135_com  '$remote_addr - $remote_user [$time_local] $request '
                                '"$status" $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for"';
              access_log  /data1/logs/www.log  www_s135_com;
      }

      server
      {
              listen  80;
              server_name  blog.zyan.cc;

              location / {
                       proxy_pass        http://blog.zyan.cc;
                       proxy_set_header   Host             $host;
                       proxy_set_header   X-Real-IP        $remote_addr;
                       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
              }

              log_format  blog_s135_com  '$remote_addr - $remote_user [$time_local] $request '
                                '"$status" $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for"';
              access_log  /data1/logs/blog.log  blog_s135_com;
      }
}

  附:Nginx 的安装方法可参照《Nginx 0.5.31 + PHP 5.2.4(FastCGI)搭建可承受3万以上并发连接数,胜过Apache 10倍的Web服务器》文章的以下段落(仅做负载均衡,无需支持PHP的安装方法):

  二、安装PHP 5.2.4(FastCGI模式)
  4、创建www用户和组,以及其使用的目录:

  三、安装Nginx 0.5.31
  1、安装Nginx所需的pcre库:
  2、安装Nginx
  3、创建Nginx日志目录
  5、启动Nginx





技术大类 » Web服务器 | 评论(97) | 引用(0) | 阅读(213913)
shz Email
2022-8-6 20:16
I read that Post and got it fine and informative. Please share more like that...  tom wang fba masterclass
shz Email
2022-8-6 20:20
I really enjoy reading and also appreciate your work.  tom wang fba masterclass
shz Email
2022-8-6 20:27
I really enjoyed reading this post, big fan. Keep up the good work andplease tell me when can you publish more articles or where can I read more on the subject?  zen arbitrage reviews
shz Email
2022-8-6 20:30
I liked your article and I hope you will have many entries or more  zen arbitrage reviews
shz Email
2022-8-6 20:33
This is also a very good post which I really enjoy reading. It is not everyday that I have the possibility to see something like this.  zen arbitrage reviews
shz Email
2022-8-7 00:09
I have been searching to find a comfort or effective procedure to complete this process and I think this is the most suitable way to do it effectively.  Clients On Demand Review
SHZZZ Email
2022-8-7 00:26
Here at this site really the fastidious material collection so that everybody can enjoy a lot.  The Palm Beach Letter Review
SHZZZ Email
2022-8-7 00:30
cool stuff you have and you keep overhaul every one of us  The Palm Beach Letter Review
SHZZZ Email
2022-8-7 00:34
If your looking for Online Illinois license plate sticker renewals then you have need to come to the right place.We offer the fastest Illinois license plate sticker renewals in the state.  Vincero Investment Academy Review
SHZZZ Email
2022-8-7 00:37
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.  Vincero Investment Academy Review
SHZZZ Email
2022-8-7 00:40
Gangaur Realtech is a professionally managed organisation specializing in real estate services where integrated services are provided by professionals to its clients seeking increased value by owning, occupying or investing in real estate.  Vincero Investment Academy Review
SHZZZ Email
2022-8-7 00:42
Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.  Project Mastermind Review
SHZZZ Email
2022-8-7 00:45
A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.  Project Mastermind Review
shz Email
2022-8-7 01:02
it's really cool blog. Linking is very useful thing.you have really helped  Clients On Demand Review
Alex
2023-8-11 14:16
Thanks for setting an example of showing Nginx simple load balancing configuration.

Alex,
Define your legal scholarship with Quality Assignment's law dissertation writing services. Our writers defy mediocrity by meticulously crafting dissertations that exemplify academic rigor and intellectual prowess.
Lucky cola
2024-2-7 13:46
Dive into a world of endless fun and adventure.  Lucky cola
分页: 5/5 第一页 上页 1 2 3 4 5 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]