1、配置文件结构图

2、作用1:静态文件服务器

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

创建2个目录
/data/www
/data/images

# 请求http://www.example.com/example.html时,对应/data/www/example.html
# 请求http://www.example.com/images/example.png时,对应

/data/images/example.png

# 每个server块通过listen和server_names来区分。

# 服务器会提取URI,然后匹配所有的location,找最长的那个。

3、作用2:代理服务器

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

所有不是以.gif/.jpg/.png结尾的请求,都走location / {},请求被转发给http://localhost:8080。

8080在接收到请求后,开始在/data/up1目录下寻找文件。

所有以.gif/.jpg/.png结尾的请求,都走location ~ \.(gif|jpg|png)$ {},开始在/data/images目录下寻找文件。

# 使用正则表达式进行匹配时,需要以~开头

3、作用3:代理请求到fastcgi服务器

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

# fastcgi服务器的地址
# 脚本文件名(绝对路径)
# 传递给脚本的参数

# 所有关于图片的请求都到/data/images目录下寻找。

nginx基础内容的更多相关文章

  1. Nginx基础整理

    目录结构如下: Nginx基础知识 Nginx HTTP服务器的特色及优点 Nginx的主要企业功能 Nginx作为web服务器的主要应用场景包括: Nginx的安装 安装环境 快速安装命令集合 各个 ...

  2. nginx 基础文档

    Nginx基础 1.  nginx安装 2.  nginx 编译参数详解 3.  nginx安装配置+清缓存模块安装 4.  nginx+PHP 5.5 5.  nginx配置虚拟主机 6.  ngi ...

  3. [转帖]nginx基础整理

    nginx基础整理 https://www.cnblogs.com/guigujun/p/6588545.html 目录结构如下: Nginx基础知识 Nginx HTTP服务器的特色及优点 Ngin ...

  4. 原创——Nginx基础

    Nginx基础 一.Nginx概述: Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx ...

  5. Nginx基础优化

    Nginx基础优化 1.隐藏nginx header版本号 1.1查看版本号 [root@Nginx ~]# curl -I http://www.yunwei.cn HTTP/1.1 200 OK ...

  6. Nginx基础详细讲解

    Nginx基础详细讲解 链接:https://pan.baidu.com/s/1xB20bnuanh0Avs4kwRpSXQ 提取码:migq 复制这段内容后打开百度网盘手机App,操作更方便哦 1. ...

  7. nginx基础(二)

    二.nginx基础配置 (1)错误指向一个页面 http状态指向指定访问页面,在 /etc/nginx/conf.d/default.conf 中配置 error_page /50x.html; er ...

  8. day63:Linux:nginx基础知识&nginx基础模块

    目录 1.nginx基础知识 1.1 什么是nginx 1.2 nginx应用场景 1.3 nginx组成结构 1.4 nginx安装部署 1.5 nginx目录结构 1.6 nginx配置文件 1. ...

  9. Nginx基础环境搭建

    1.下载docker toolbox https://mirrors.aliyun.com/docker-toolbox/windows/docker-toolbox/ 2.选择好安装目录 一路nex ...

随机推荐

  1. C语言中的数据类型转换函数

    头文件#include<stdlib.h> 1. 函数名: atof 功 能: 把字符串转换成浮点数 用 法: double atof(const char *nptr); 2.函数名: ...

  2. centos安装vbox addition

    在centos下安装vbox addition需要下载当前内核的头文件 yum install kernel-devel 但是下载了头文件后,仍然失败,原来是下载的头文件与当前的内核版本不对应, 于是 ...

  3. 专题:NFSv4 file server

    Network File System (NFS) is a file system protocol that allows client machines to access network at ...

  4. 进程共享变量#pragma data_seg用法

    #pragma data_seg介绍 用#pragma data_seg建立一个新的数据段并定义共享数据,其具体格式为: #pragma data_seg ("shareddata" ...

  5. linux 创建用户并限制其访问目录

    1.创建用户及访问目录 useradd test1 -d /usr/share/webapps/test -M 设置密码 passwd  test1 将访问目录权限全部赋予用户 chown -R te ...

  6. lua redis 操作

    https://redis.io/commands/keys 遍历redis里面的所有key ,还能进行模糊匹配, 这样就省去了对key的手动过滤了 比如 keys term_info* ) &quo ...

  7. [转]WPF的依赖属性是怎么节约内存的

    WPF升级了CLR的属性系统,加入了依赖属性和附加属性.依赖属性的使用有很多好处,其中有两点是我认为最为亮眼的: 1)节省内存的开销; 2)属性值可以通过Binding依赖于其它对象上,这就使得我的数 ...

  8. php Excel导出功能

    /** * * execl数据导出 */ function exportOrderExcel2($title, $cellName, $data) { //引入核心文件 vendor("PH ...

  9. C++ 短信验证码/通知 - 代码示例

    //接口类型:互亿无线触发短信接口,支持发送验证码短信.订单通知短信等. // ///////////////////账户注册:请通过该地址开通账户http://user.ihuyi.com/regi ...

  10. Bootstrap快速入门并且建立常用模板

    对于移动端,能够快速搭建网站,操作相对简单 ,更容易掌握,这篇文章就介绍一下BootStrap 一  什么是Bottstrap 一个前端开发的框架,Bootstrap,来自 Twitter,是目前很受 ...