由一个主配置文件和一些辅助配置文件构成,位于conf目录下

配置指令 指令参数(配置指令对应的值)

token串分为简单字符串或复合配置块({})

简单配置项 复杂配置项

error_page 500 502 /50x.html;

location / {
root /home/html;
index index.html index.htm
}

根据逻辑意义分成了多个作用域,即配置指令上下文

nginx支持的指令上下文,即作用域

main

http

server

location

mail

指令上下文,可能有包含的情况出现。例如,通常http上下文和mail上下文一定是出现在main上下文里。

user nobody;
worker_processes 1;
error_log logs/error.log info;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name www.linuxdc.com;
}
}

The basic configuration format

Nginx global configuration parameters

Using include files

The HTTP server section

The virtual server section

Locations - where, when and how

The mail server section

Full sample configuration

Loadbalance

upstream web_backend {
server 10.11.12.51
server 10.11.12.52
} server {
listen ; location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web_backend;
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////

Starting, Stopping, and Reloading Configuration

nginx -s stop --fast shutdown
nginx -s quit --graceful shutdown
nginx -s reload --reloading the config file
nginx -s reopen --reopening the log files kill -s QUIT
ps -ax | grep nginx

Serving Static Content

/data/www --index.html
/data/images --some images

http {
server {
location / {
root /data/www;
} location /images/ {
root /data;
}
}
}

http://localhost/images/example.png -- /data/images/example.png
http://localhost/some/example.html -- /data/www/some/example.html

nginx -s reload

Find out reason in access.log or error.log, in the directory of /usr/local/nginx/logs or /var/log/nginx

Setting Up a Simple Proxy Server

http {
server {
location / {
proxy_pass http://localhost:8080;
} location ~ \.(gif|jpg|png)$ {
root /data/images;
}
}
}

Setting Up FastCGI Proxying

http {
server {
location / {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
} location ~ \.(gif|jpg|png)$ {
root /data/images;
}
}
}

Mater Nginx(2) - A Configuration Guide的更多相关文章

  1. Nginx and PHP-FPM Configuration and Optimizing Tips and Tricks

    原文链接:http://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips- ...

  2. P6 EPPM Installation and Configuration Guide 16 R1 April 2016

    P6 EPPM Installation and Configuration Guide 16 R1         April 2016 Contents About Installing and ...

  3. P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1

    P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1       May ...

  4. Installation and Configuration Guide

    Harbor can be installed by one of three approaches: Online installer: The installer downloads Harbor ...

  5. Ehcache(2.9.x) - Configuration Guide, Configuring Cache

    About Ehcache Configuration Ehcache supports declarative configuration via an XML configuration file ...

  6. In-App Purchase Configuration Guide for iTunes Connect---(一)----Introduction

    Introduction In-App Purchase is an Apple technology that allows your users to purchase content and s ...

  7. Nginx Installation、Configuration、Rreverse Proxy、Load Balancing Learning

    目录 . Nginx简介 . Nginx安装部署 . Nginx安全配置 . Nginx反向代理实践 . Nginx负载均衡实践 1. Nginx简介 0x1: Nginx的基本特性 Nginx(&q ...

  8. Ehcache(2.9.x) - Configuration Guide, Configuring Storage Tiers

    About Storage Tiers Ehcache has three storage tiers, summarized here: Memory store – Heap memory tha ...

  9. Openstack: Single node Installation and External Network Accessing Configuration Guide

    Summary of installation Step 0: Prerequisites Step 1: Create Openstack hostsystem Step 2: Config Ope ...

随机推荐

  1. CAF(C++ actor framework)使用随笔(projection 用法)(一)

    最近干活在写毕设,用到了CAF,看了文档,发现了一些小坑,自己摸索写点随笔.(CAF的github网站 https://github.com/actor-framework/actor-framewo ...

  2. 还原数据库备份文件时,关于“System.Data.SqlClient.SqlError:媒体集有2个媒体簇,但只提供了1个。必须提供所有成员”的处理方式

    好久没写博客了,最近在做毕设的权限管理模块,今天在还原数据库文件时,遇到了“System.Data.SqlClient.SqlError:媒体集有2个媒体簇,但只提供了1个.必须提供所有成员”这个错误 ...

  3. javascript获取url中对应参数的方法

    利用正则表达式和location.search方法,可以简便的获取到对应的参数:   function getQueryString(name) {var reg = new RegExp(" ...

  4. (转载)c++builder/delphi中透明panel及透明窗口的实现方法_delphi教程

    c++builder/delphi中透明panel及透明窗口的实现方法_delphi教程 可能大多数程序员会问:透明窗口,特别是透明Panel有什么应用价值呢?可别小看它们哦,下面我就来讲讲他们的巨大 ...

  5. <a>作Form表单提</a>

    1. Form表单<%using (Html.BeginForm("AddRoles", "RoleManage", FormMethod.Post, n ...

  6. hdu 2767 Proving Equivalences

    Proving Equivalences 题意:输入一个有向图(强连通图就是定义在有向图上的),有n(1 ≤ n ≤ 20000)个节点和m(0 ≤ m ≤ 50000)条有向边:问添加几条边可使图变 ...

  7. 中国.net域名网站的“前世今生”,那些年的光辉

    1987年9月的一天,中国的第一封电子邮件成功发出,邮件的内容大致是“跨越长城,走向世界”,在当时,没有人会想到十年后中国的互联网开始萌芽,并发展成今天的繁荣.1994年,“巴黎统筹委员会”的解散消除 ...

  8. Static File Middleware

    [ASP.NET Core] Static File Middleware   前言 本篇文章介绍ASP.NET Core里,用来处理静态档案的Middleware,为自己留个纪录也希望能帮助到有需要 ...

  9. ios阻止锁屏 --老代码,供参考

    // Disable the idle timer [[UIApplication sharedApplication] setIdleTimerDisabled: YES];    // Or fo ...

  10. java的装箱与拆箱

    在 JDK1.5 引入自动装箱和拆箱的机制后,包装类和基本类型之间的转换就更加轻松便利了.那什么是装箱和拆箱呢?我们分别来看下装箱:把基本类型转换成包装类,使其具有对象的性质,又可分为手动装箱和自动装 ...