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. mongodb导入csv

    主要介绍使用自带工具mongoimport工具将 CSV 格式数据导入到 MongoDB 的详细过程. 由于官方提供了mongoimport工具,所以实际上导入 CSV 格式数据的过程非常简单,再次体 ...

  2. 服务器安装TeamViewer 13

    服务器安装TeamViewer 13 服务器上安装TeamViewer,网上找了个教程开始安装,里面有坑,安装时要根据自己的情况而定.Linux系统更新太快,网上教程可能会有一些出入. TeamVie ...

  3. 截取url中的某个字符串后面的值

    获取到当前网址 var url = window.location.href; http://localhost:8080/exam_questions?type=3 //获取url中的参数 func ...

  4. Airbnb React/JSX 编码规范

    Airbnb React/JSX 编码规范 算是最合理的React/JSX编码规范之一了 内容目录 基本规范 Class vs React.createClass vs stateless 命名 声明 ...

  5. 分析无法进入Linux系统的原因

    上文:http://www.cnblogs.com/long123king/p/3549701.html 1: static int __init kernel_init(void * unused) ...

  6. Linux 下通过mail命令发送邮件

    mail -s "测试"  1968089885@foxmail.com 需要先配置smtp服务器

  7. WordPress .gitignore

    # ----------------------------------------------------------------- # .gitignore for WordPress @salc ...

  8. ajax-jq

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. leetcode-168周赛-1295-统计位数为偶数的数字

    题目描述: 方法一:O(N) class Solution: def findNumbers(self, nums: List[int]) -> int: ans=0 for num in nu ...

  10. leetcode-回溯

    题17: 方法一:回溯 class Solution: def letterCombinations(self, digits: str) -> List[str]: res = [] dic ...