nginx配置文件详解

2018-11-28  本文已影响14人  超鸽带你飞

基本就分为以下几块:

main
events   {
  ....
}
http        {
  ....
  upstream myproject {
    .....
  }
  server  {
    ....
    location {
        ....
    }
  }
  server  {
    ....
    location {
        ....
    }
  }
  ....
}

nginx配置文件主要分为六个区域:
main(全局设置)、events(nginx工作模式)、http(http设置)、
sever(主机设置)、location(URL匹配)、upstream(负载均衡服务器设置)。

1. main模块

2. events 模块

events {
    use epoll; #linux平台
    worker_connections  1024;
}

3. server 模块

4. location 模块

location / {
    root   /Users/yangyi/www;
    index  index.php index.html index.htm;
}

5. upstream 模块

upstream iyangyi.com{
    ip_hash;
    server 192.168.12.1:80;
    server 192.168.12.2:80 down;
    server 192.168.12.3:8080  max_fails=3  fail_timeout=20s;
    server 192.168.12.4:8080;
}
上一篇 下一篇

猜你喜欢

热点阅读