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 ...
随机推荐
- java url中文参数乱码
String city=new String(city_name.getBytes("ISO-8859-1"), "UTF-8");
- Idea 导入项目不能运行
1.项目结构里面配置sdk,配置output输出目录 2.配置语言等级 配置src源文件目录 配置目录里面添加application,添加main class
- TLS/SSL 协议 - ClientHello
ClientHello 在一次新的握手流程中,ClientHello消息总是第一条消息.这条消息将客户端的功能和首选项传送给服务器.客户端会在新建连接后,希望重新协商或者响应服务器发起的重新协商请求( ...
- VMware Pro v14.1.1 官方版本及激活密钥
热门虚拟机软件VMware Workstation Pro现已更新至14.1.1,14.0主要更新了诸多客户机操作系统版本,此外全面兼容Wind10创建者更新.12.0之后属于大型更新,专门为Win1 ...
- flink收藏博客
1.https://blog.csdn.net/liguohuabigdata/article/category/7279020 2.http://wuchong.me 3.https://www.j ...
- PAT_A1025#PAT Ranking
Source: PAT A1025 PAT Ranking Description: Programming Ability Test (PAT) is organized by the Colleg ...
- 45-Ubuntu-用户管理-10-chmod修改文件|目录权限
1.将a.py的权限修改为u=rwx, g=r-x, o=r--. 2.将目录test及子目录和文件权限修改为u=rwx, g=rwx, o=r-x.
- 【单调队列优化】[CF372C] Watching Fireworks is Fun
突然发现我可能单调队列都打不来了...我太菜了... 这道题显然有$$f[i][j]=min\{f[i-1][k]+\vert j-a[i] \vert\}$$ 则$ans=\sum_{i=1}^{m ...
- 设计Twitter的api
355. Design Twitter 题意:设计Twitter的API,实现以下功能. postTweet(userId, tweetId): Compose a new tweet. getNew ...
- WSGI——python-Web框架基础
1. 简介 WSGI WSGI:web服务器网关接口,这是python中定义的一个网关协议,规定了Web Server如何跟应用程序交互.可以理解为一个web应用的容器,通过它可以启动应用,进而提 ...