由一个主配置文件和一些辅助配置文件构成,位于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. Java中的面向对象

    Java中的面向对象 在软件开发的学习中, 我最先接触的开发语言就是java,但都是简单的函数和循环数组的应用.说道面向对象,第一次看到这个词的时候还是在C#的学习过程中,我记得当时PPT上霸气的解释 ...

  2. Linux之CentOS下vsftp安装及配置相关操作

    1.安装ftps——vsftpd: #yum install vsftpd 2.指定上传下载目录配置: 如:用户名:xxx,需指定目录:/xxx/xxx #useradd -d /xxx/xxx -s ...

  3. jQuery—一些常见方法(3)【width(),innerWidth(),outerWidth()】

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. git 使用事项

    基本安装可查看 http://help.github.com 如果删除了本地的文件,要恢复相关文件,在github存在(别人增加的),则:git pull <远程主机名> <远程分支 ...

  5. mysql用户管理,权限管理

    mysql权限 相关操作: 授予的权限分为四组: 列权限:和表中的一个具体列相关,例如:使用update 语句更新test表中name 列的值 表权限:和一个具体的表的所有数据相关,例如:使用 sel ...

  6. asp.net mvc上传头像加剪裁功能介绍

    正好项目用到上传+剪裁功能,发上来便于以后使用. 我不能告诉你们其实是从博客园扒的前台代码,哈哈. 前端是jquery+fineuploader+jquery.Jcrop 后台是asp.net mvc ...

  7. fedora 非root用户访问socket 没用权限

    在非root用户下执行基于Libpcap库编写的应用程序时不能正常运行,原因是由于libpcap库使用raw socket的套接字.而Raw Socket的使用需要root权限,否则raw socke ...

  8. postal.js使用

    requirejs.config({ //默认情况下模块所在目录为js/lib baseUrl: './', //当模块id前缀为app时,他便由js/app加载模块文件 //这里设置的路径是相对与b ...

  9. numpy+scipy+matlotlib+scikit-learn的安装及问题解决

    NumPy(Numeric Python)系统是Python的一种开源的数值计算扩展,一个用python实现的科学计算包.它提供了许多高级的数值编程工具,如:矩阵数据类型.矢量处理,以及精密的运算库. ...

  10. 【加密】C#.NET 各种加密解密

    包括:AES/DES/Base64/RSA/MD5/SHA256 http://www.sosuo8.com/article/show.asp?id=3083 http://blog.csdn.net ...