nginx基础内容
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基础内容的更多相关文章
- Nginx基础整理
目录结构如下: Nginx基础知识 Nginx HTTP服务器的特色及优点 Nginx的主要企业功能 Nginx作为web服务器的主要应用场景包括: Nginx的安装 安装环境 快速安装命令集合 各个 ...
- nginx 基础文档
Nginx基础 1. nginx安装 2. nginx 编译参数详解 3. nginx安装配置+清缓存模块安装 4. nginx+PHP 5.5 5. nginx配置虚拟主机 6. ngi ...
- [转帖]nginx基础整理
nginx基础整理 https://www.cnblogs.com/guigujun/p/6588545.html 目录结构如下: Nginx基础知识 Nginx HTTP服务器的特色及优点 Ngin ...
- 原创——Nginx基础
Nginx基础 一.Nginx概述: Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx ...
- Nginx基础优化
Nginx基础优化 1.隐藏nginx header版本号 1.1查看版本号 [root@Nginx ~]# curl -I http://www.yunwei.cn HTTP/1.1 200 OK ...
- Nginx基础详细讲解
Nginx基础详细讲解 链接:https://pan.baidu.com/s/1xB20bnuanh0Avs4kwRpSXQ 提取码:migq 复制这段内容后打开百度网盘手机App,操作更方便哦 1. ...
- nginx基础(二)
二.nginx基础配置 (1)错误指向一个页面 http状态指向指定访问页面,在 /etc/nginx/conf.d/default.conf 中配置 error_page /50x.html; er ...
- 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. ...
- Nginx基础环境搭建
1.下载docker toolbox https://mirrors.aliyun.com/docker-toolbox/windows/docker-toolbox/ 2.选择好安装目录 一路nex ...
随机推荐
- (3)Redis conifg
redis.windows-service.conf Redis-x64-3.2.100 # Redis configuration file example # Note on units ...
- (¥1011)->(一千零一拾一元整)输出
public class RenMingBi { /** * @param args add by zxx ,Nov 29, 2008 */ private static final char[] d ...
- 自己写Linux module来收集buddy info
1 编写代码pslist.c 1: #include<linux/init.h> 2: #include<linux/module.h> 3: #include<linu ...
- TIKA环境配置
本章将指导完成设置Apache Tika在Windows和Linux的配置过程.用户管理是必要的,同时安装了Apache Tika. 系统要求 JDK Java SE 2 JDK 1.6 或以上 内存 ...
- static变量、static函数与普通变量、普通函数的区别
转自:http://blog.163.com/sunshine_linting/blog/static/44893323201191294825184/ 全局变量(外部变量)的说明之前再冠以stati ...
- 0 ‘+new Array(017)’ 输出? js+相当于Number()类型转换
网站搬迁,给你带来的不便敬请谅解! http://www.suanliutudousi.com/2017/10/20/new-array017-%E8%BE%93%E5%87%BA%EF%BC%9F- ...
- qt5.9.1 VS2017 qalgorithms.h
qt5.9.1只有VS2017 64位支持, 在32位工程下会出现关于qalgorithms.h的错误,参考以下内容修改该头文件解决: https://codereview.qt-project.or ...
- css3条纹进度条
新建div,取名progress,如下 <div class="progress"></div> 在里面插入条纹进度条,以及进度显示文本进度: <di ...
- TOP和PS aux命令显示出来的栏目所代表的意思
USER: 行程拥有者 PID: pid %CPU: 占用的 CPU 使用率 %MEM: 占用的记忆体使用率 VSZ: 占用的虚拟记忆体大小 RSS: 占用的记忆体大小 TTY: 终端的次要装置号码 ...
- 在windows server 2012中安装完oracle 11 client如何使用
1.首先要添加监听配置,这样才可以没有报错的连接上服务器,至于如何添加,请自行搜索. 2.打开SQL Plus连接oracle server端,这里因为是小白,看到命令行界面上来就需要输入用户名密码 ...