由一个主配置文件和一些辅助配置文件构成,位于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. 初识XML及简单工厂运用--网络电视精灵

    网络电视精灵 任务描述 1. 解析XML文件中的数据 三个简单的xml文件; <?xml version="1.0" encoding="utf-8" ? ...

  2. [java学习笔记]JDK的安装和环境变量的配置

    1.JDK的下载和安装 jdk(java development kit)是java提供给我们的一套java开发工具,它必运行在JVM(java虚拟机)上,java语言的跨平台性就是利用java运行在 ...

  3. redis 常用操作命令

    操作相关的命令连接 quit:关闭连接(connection)auth:简单密码认证 持久化 save:将数据同步保存到磁盘bgsave:将数据异步保存到磁盘lastsave:返回上次成功将数据保存到 ...

  4. Android Studio第一次提交git使用

    安装: Git客户端网址:http://git-scm.com/download/ 根据自己的使用平台下载对应的客户端.这里以Mac系统为例,当客户端软件安装配置完毕后,打开AS的配置面板,找到Git ...

  5. JS判断是否微信浏览器

    JS判断是否微信浏览器 function isWeixinBrowser(){ var ua = navigator.userAgent.toLowerCase(); return (/microme ...

  6. jquery中邮箱地址 URL网站地址正则验证实例代码

    QQ网站有一个网站举报的功能,看了一些js代码觉得写得很不错,我就拿下来了,下面是一个email验证与url网址验证js代码,分享给大家 email地址验证 复制代码代码如下: function ch ...

  7. Ms SQLServer中的Union和Union All的使用方法和区别

    Ms SQLServer中的Union和Union All的使用方法和区别 SQL UNION 操作符 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 ...

  8. Java学习-集合(转)

    在编写java程序中,我们最常用的除了八种基本数据类型,String对象外还有一个集合类,在我们的的程序中到处充斥着集合类的身影!java中集合大家族的成员实在是太丰富了,有常用的ArrayList. ...

  9. SD卡FAT32文件系统格式

    一.声明 1.本文来源和主旨 2.本文测试环境 二.SD卡FAT文件系统 1.SD卡FAT32文件系统的整体布局 2.FAT文件系统简介 ① 文件分配表 ② 目录项 三.DBR(DOS BOOT RE ...

  10. Unity3d Shader开发(四)UsePass ,GrabPass ,SubShader Tags

    (一)UsePass 命令 使用 来自另一个着色器的命名通道. Syntax 语法 UsePass "Shader/Name" 插入所有来自给定着色器中的给定名字的通道.Shade ...