创建目录
关闭 iptables规则
停用selinux
Nginx命令
Nginx是一个开源且高性能,可靠的http中间件,代理服务。
中间件
:可以直接调用操作系统,也可以调用应用。使网站更有层次性,便于开发维护。中间件可以获取web请求,并把请求分发给操作系统或者应用,也可以分发给其他中间件,也可以通过应用发给其他中间件。
为什么选择Nginx
:
IO多路复用epoll
轻量级:功能模块少,代码模块化。
CPU亲和。减少额外的性能损耗。
是一种把CPU核心和Nginx工作进程保定方式,把每个worker进程固定
在一个CPU上执行,减少CPU开支。
sendfile工作机制。
Nginx快速搭建
:
vim /etc/yum.repos.d/nginx.repo
复制一下代码:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
其中将 OS 改成你的系统 这里我用的是centos OSRELEASE改成你的操作系统版本 我用的是centos7 所以 这里改成 7
所以这里改成:
baseurl=http://nginx.org/packages/centos/7/$basearch/
yum list |grep nginx 查看yum源中nginx版本
yun install nginx 安装nginx
通过nginx -v 查看版本
通过yum安装,其实是安装一个一个rpm包
sudo /usr/local/nginx/sbin/nginx -s reload
rpm -ql nginx 查看已经安装的服务所配置的文件以及对应的目录
查看输出,在 etc , usr , var 三个目录下都有安装
Linux 操作系统下 etc 目录安装的是系统的核心配置文件,同理Nginx中也适用。
以下只要没写的框框,就是同上
编译选项 | 是什么 | 作用 |
---|---|---|
/etc/logrotate.d/nginx | 配置文件 | Nginx日志轮转,用于logrotate服务的日志切割(用系统的logrotate服务进行的) |
/etc/nginx | 目录,配置文件 | Nginx主配置文件 |
/etc/nginx/nginx.conf | 主要配置 | Nginx启动的时候,读nginx.conf |
/etc/nginx/conf.d | 目录 | |
/etc/nginx/conf.d/default.conf | 配置文件 | 安装后默认执行的server加载 |
/etc/nginx/fastcgi_params | 配置文件 | cgi配置相关,fastcgi配置 |
/etc/nginx/uwsgi_params | uwsgi配置 | |
/etc/nginx/scgi_params | scgi配置 | |
/etc/nginx/koi-utf | 配置文件 | 编码转换映射转化文件 |
/etc/nginx/koi-win | ||
/etc/nginx/win-utf | ||
/etc/nginx/mime.types | 配置文件 | 设置http协议的Content Type与扩展名对应关系(在ContentType中保存了返回的文件类型,.jpg,.json之类,nginx要把ContentType和扩展名建立对应关系,当Nginx无法识别扩展名的时候就需要去配置mime.types文件,进行添加) |
/user/lib/systems/system/nginx-debug.service | 配置文件 | 用于配制出系统守护进程管理器管理方式 |
/user/lib/systems/system/nginx.service | ||
/etc/sysconfig/nginx | ||
/etc/sysconfig/nginx-debug | ||
/usr/lib64/nginx/modules | 目录 | Nginx模块目录 |
/etc/nginx/modules | ||
/usr/sbin/nginx | 命令 | Nginx服务的启动管理的终端命令 |
/usr/sbin/nginx-debug | ||
/usr/share/doc/nginx-你的nginx版本 | 文件,目录 | Nginx的手册和帮助文件 |
/usr/share/doc/nginx-你的nginx版本/COPYRIGHT | ||
/usr/share/man/ma8/nigninx.8.gz | ||
/var/cache/nginx | 目录 | Nginx的缓存目录 |
/var/log/nginx | 目录 | Nginx的日志目录 |
编译选项 | 作用 |
---|---|
–prefix=/usr/share/nginx | 安装目的目录或路径(nginx主目录) |
–sbin-path=/usr/sbin/nginx | nginx的执行命令 |
–modules-path=/usr/lib64/nginx/modules | nginx的模块 |
–conf-path=/etc/nginx/nginx.conf | nginx的配置文件 |
–http-log-path=/var/log/nginx/access.log | 访问日志 |
–error-log-path=/var/log/nginx/error.log | 错误日志目录 |
–lock-path=/var/lock/nginx.lock | 锁 |
–pid-path=/run/nginx.pid | pid文件 |
–http-client-body-temp-path=/var/lib/nginx/body | 执行对应模块时,Nginx所保留的临时性文件 |
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi | |
–http-proxy-temp-path=/var/lib/nginx/proxy | |
–http-scgi-temp-path=/var/lib/nginx/scgi | |
–http-uwsgi-temp-path=/var/lib/nginx/uwsgi | |
–user=nginx | 设定Nginx进程启动的用户和组 |
–group=nginx | (可以自行配制root用户,安全性) |
–with-cc-opt=parameters | 这是额外的参数将被添加到CFLAGS变量 |
–with-ld-opt=parameters | 设置附加的参数,链接系统库 |
在nginx中的nginx.conf文件:cd /etc/nginx/ 之后 vim nginx.conf
http {
include /etc/nginx/mime.types; #子配置文件
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';//“log_format”定义日志类型
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65; #设置客户端服务端访问超时时间,默认65s
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
查看default.conf,cd /etc/nginx/conf.d 之后 vim default.conf
listen 代表监听的端口,这里默认80端口
server-name 主机名(可以替换)
location 一个server中可以有多个location,当没有其他的访问路径时默认是“/” root是存放路径,index 是html文件
error_page 错误类型,以及其对应的错误网站
修改完配置文件之后需要重启nginx
server{
listen 80; # 监听端口
server_name localhost; # 服务名字/域名访问地址 baidu.com
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / { # 服务名字 与其 对应的访问路径,如果是 ‘/’代表所有访问都通过下面的路径
root /usr/share/nginx/html; # 根 路径
index index.html index.htm; # 默认访问的页面,如果没有index.html则访问index.htm
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html; # 错误号与访问错误对应的的文件,可以手动添加
location = /50x.html {
root /usr/share/nginx/html; # 错误对应的文件的位置
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
}
“>”是request。“<”是response
> GET / HTTP/1.1 #请求方式位GET方式
> User-Agent: curl/7.35.0. #请求头是curl
> Host: www.csdn.net #访问的网址是csdn
> Accept: */*
< HTTP/1.1 200 OK #200 是正常访问之后返回的值
* Server openresty is not blacklisted
< Server: openresty
< Date: Tue, 04 Sep 2018 05:32:19 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Keep-Alive: timeout=20
配置语法大概如下
Syntax: log_format name [escape=default|json] string ...;
Default:log_format combined "...";
Context:http。#必有
编辑/etc/nginx/nginx.conf 文件,使其能够输出请求头
htt{
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$http_user_agent' '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_send "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
}
curl/7.29.0127.0.0.1 - - [21/Apr/2019:18:16:19 +0800] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
# 在access.log文件中查看到的信息
Nginx内置变量(太多了,直接丢官网上的)
再看回nginx.conf文件中的log_format
http_stub_status_module
配置语法:
Syntax: stub_status; # 写法
Default:-- # 默认值
Context:server, location # 应该配置在什么地方
配置:
location /mystauts{
stub_status;
}
Active connections: 1 #Nginx 当前活跃的状态数
server accepts handled requests
2 2 3 # Nginx 接受握手的总次数 处理的连接数 总的请求数
# 一般 握手数 与 连接数相同,表示没有丢失
Reading: 0 Writing: 1 Waiting: 0
# 上面三个表示当前的状态
# 第一个 正在读的个数 第二个 正在往Nginx写的个数 第三个等待个数
http_random_index_module 模块
目录中随机选择一个文件作为主页
很少用,但是也是有用的,比如随机生成不同主题的主页给用户不同体验
配置语法
Syntax:random_index on|off; # 有 on 和 off可供选择
Default:random_index off; # 默认关闭
Context:location # 配置在location中
location / {
root /opt/code;
#index index.html index.htm;
random_index on;
}
http_sub_module 模块
Nginx服务端在给客户端response的http内容的时候,对http的内容进行替换
用的也比较少
常用语法
Syntax : sub_filter string replacement;
# string 表示要替换的内容
# replacement 替换后的对象,替换后的内容
Default : --
Context:http, server, location
Synatx : sub_filter_last_modified on|off;
# Nginx的服务端完成与客户端(浏览器),每次请求校验服务端内容是否有所更新
# 一般记录一串时间格式
Default : sub_filer_last_modified off;
Context : http, server, location;
Synatx : sub_filter_once on|off;
# 匹配所有html中的第一个,还是匹配所有指定的字符串
Default : sub_filter_once on;
# on 只修改匹配道德第一个 html内容
# off 把所有html指定内容都进行匹配
Context : htpp,server, locaiton
实战经历
创建测试html
<html>
<head>
<meta charset="UTF-8">
<title>testtitle>
head>
<body>
<a>qwera>
<a>1234a>
<a>5678a>
<a>qwera>
body>
html>
location /{
root /opt/code;
index index.html index.tm;
sub_filter 'qwer' 'asdf';
# 更新 qwer 为 asdf
}
location /{
root /opt/code;
index index.html index.tm;
sub_filter 'qwer' 'asdf';
sub_filter_once off; # 让其全局替换
# 更新 qwer 为 asdf
}
连接请求限制
请求频率限制
-limit_req_module
Http请求建立在一次TCP链接基础上
一次TCP请求至少产生一次Http请求
配置语法
Syntax : limit_conn_zone key zone=name:size;
# 如果要限制连接,就需要存储各个连接的状态,因此需要开辟空间存储
# limit_conn_zone 就是开辟的空间
# key 为 限制的变量,例如ip等
# zone 为 name为申请空间名字,为下面的limit_conn中的zone做准备
# size 为开辟空间的大小
Default: --
Context : http
Syntax : limit_conn zone number;
# zone 为上述的 开辟空间的 zone 的 name
# number 限制同一时间最多有多少个连接数
Dafault : --
Context : http,server, location;
Syntax : limit_req_zone key zone=name:size rate=rate;
# 这里name,size同上,是为了后面做准备
# rate 速率,表示请求限制是多大,一般以秒为单位。表示每秒限制多少个
Default:--
Context:http
Syntax : limit_req zone=name [burst=number] [nodelay]
# zone 为上述的 zone 的 name
# 后面两个 [] 中的参数默认不需要配置
Default: --
Context:http,server,location
http{
limit_conn_zone $binary_remote_addr zone=conn_zone:1m;
# 这样的配配置,表明以ip为key,来限制每个ip访问的时候,最多只能有一个在线,否则其余的都要返回不可用。
limit_req_zone $binary_remote_addr zone=req_zone:1m rate=1r/s;
# binary_remote_addr 是访问的客户端ip地址
# remote_addr也是客户端地址,但是binary_remote_addr比remote_addr节省10个字节的空间
# 申请空间名字是req_zone,大小为1m
# 限制 同一个ip 一秒只能访问一次
server {
listen 80;
server_name localhost;
location / {
root root;
# limit_conn conn_zone 1;
# limit_req zone=req_zone burst=3 nodelay;
# limit_req zone=req_zone burst=3;
# limit_req zone=req_zone;
index index.html index.htm;
#random_index on;
}
}
}
ab 命令运行后,命令行出现提示
其中 Non-2xx responses: 19,表示非200的请求有19次
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: nginx/1.14.0
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /
Document Length: 169 bytes
Concurrency Level: 20
Time taken for tests: 0.004 seconds
Complete requests: 20
Failed requests: 19
(Connect: 0, Receive: 0, Length: 19, Exceptions: 0)
Write errors: 0
Non-2xx responses: 20
Total transferred: 14208 bytes
HTML transferred: 10372 bytes
Requests per second: 4663.09 [#/sec] (mean)
Time per request: 4.289 [ms] (mean)
Time per request: 0.214 [ms] (mean, across all concurrent requests)
Transfer rate: 3235.02 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.2 1 1
Processing: 1 2 0.3 2 3
Waiting: 0 2 0.4 2 2
Total: 1 3 0.4 3 3
Percentage of the requests served within a certain time (ms)
50% 3
66% 3
75% 3
80% 3
90% 3
95% 3
98% 3
99% 3
100% 3 (longest request)
查看 /var/log/nginx/error.log 日志文件
[error] 9893#0: *169 limiting requests, excess: 0.997 by zone "req_zone",
由此可见,我们配置限制请求成功,只有第一次请求成功,而后面19次都失败了
ab 命令运行后,命令行出现提示
其中 Non-2xx responses: 16,表示非200的请求有16次
Concurrency Level: 20
Time taken for tests: 0.004 seconds
Complete requests: 20
Failed requests: 16
(Connect: 0, Receive: 0, Length: 16, Exceptions: 0)
Write errors: 0
Non-2xx responses: 16
由此可见,总共20次请求,除了1个正常访问,3个延迟请求,其他16个全部返回503错误
Syntax : allow address | CIDR | unix: |all;
# address:允许的 ip 地址
# CIDR:允许的网段
# unix :允许socket方式访问
# all : 允许所有
Default:----
Context:http,server,location,limit_except
Syntax :deny address | CIDR | unix:|all;
# 这里是禁止访问,参数同上
Default:--
Context:http,server,location,limit_except
配置访问限制
~ ^/ 是Nginx 的一个正则匹配
可以自行百度:https://www.cnblogs.com/koal/p/6915106.html
location ~ ^/admin.html {
root html;
deny 61.136.151.252;
allow all;
index index.html;
}
通过访问127.0.0.1/admin.html 会出现403错误
location ~ ^/admin.html {
root html;
allow 61.136.151.252;
deny all;
index index.html;
}
设置只有我能访问,其他ip都不能访问
http_access_module的局限性
http_x_forwarded_for作为解决方式的一种
作为Nginx访问控制的一种方式
http_x_forwarded_for = Client IP, Proxy(1) IP, Proxy(2) IP;
结合geo模块作为解决局限性方式的一种
参考博客
https://www.cnblogs.com/HKUI/articles/7812927.html
Synatx: auth_basic string | off;
Default : auth_basic off;
Context : http, server, location, limit_except
Synatx : auth_basic_user_file file;
Default : --;
Context : http, server, location, limit_except
file表示文件路径
存储用户用户名和密码
name1:passwd1
name2:passwd2:comment
name3:passwd3
创建密码文件 ** htpasswd -c …/conf/auth_conf cong**
编写 nginx.conf文件
location ~ ^/admin.html {
root html;
auth_basic "Auth access test! input your passward";
auth_basic_user_file /usr/local/nginx/conf/auth_conf;
index index.html;
}
http_auth_basic_module的局限性
解决方案
类型 | 种类 |
浏览器端渲染 | HTML, CSS, JS |
图片 | JPEG,GIF,PNG |
视频 | FLV,MPEG |
文件 | TXT,等任一下载文件 |
配置语法-文件读取
Syntax : sendfile on|off;
Syntax : sendfile off;
Context : http, server, location, if in location
引读:–with-file-aio 异步文件读取
Syntax : tco_nopush on | off;
Default : tcp_nopush off;
Context : http, server, location
-tcp_nodelay
Syntax : tcp_nodelay on|off;
Default : tcp_nodelay on;
Context : http,server, location;
配置语法 - 压缩
Syntax : gzip on | off
Default : gzip off;
Context : http, server, location, if in location
Syntax : gzip_comp_level level;
Default : gzip_comp_level 1;
Context : http, server, locaiton;
Syntax : gzip_http_version 1.0|1.1;
Default : gzip_http_version 1.1;
Context : http, server, locaiton;
扩展Nginx压缩模块
sendfile on;
location ~ .*\.(jpg|gif|png)${
#gzip on;
#gzip_http_version 1.1;
#gzip_comp_level 2;
#gzip_types text/plain application/javascript applicaiton/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png application/xml;
root /opt/app/image;
}
location ~ .*.\.(txt|xml) ${
#gzip on;
#gzip_http_version 1.1;
#gzip_comp_level 1;
#gzip_types text/plain application/javascript applicaiton/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png application/xml;
root /ope/app/doc;
}
location ~ ^/download {
# gzip_static on;
tcp_nopush on;
root /opt/app/down
}
图片确实有所减小,是进行了压缩效果
文本的压缩力度比较大
HTTP协议定义的缓存机制(如:Expires;Cache-control等)
如果浏览器没有本地缓存
如果浏览器有本地缓存
校验过期机制
location ~ .*\.(html|htm)$ {
#expires 24h; #设置过期时间为24小时
root html;
}
Syntax : add_header name value [always];
Default : ---
Context : http, server, location, if in location
location ~ .*\.(htm|html)$ {
add_header Access-Control-Allow-Origin http://www.test.com;
# add_header Access-Control-Allow-Origin *; 允许所有站点都能跨域
# 上面的 * 的写法,超级,不安全!!!!!!!!!
add_header Access-Control-Methods GET,POST,PUT,DELETE,OPTIONS;
root html;
}
防止资源被盗用(非正常用户访问)
http_refer 防盗链配置模块
Syntax : valid_referers none | blocked | server_names | string...;
Default : --
Context : server, location
其实access.log 默认是开启 http_refer 的,如果没有开启也可以手动开启
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
<html>
<head>
<meta charset="UTF-8">
<title>testtitle>
head>
<body stylel="background-color:read;">
<img src="http://127.0.0.1/nginx1.png" />
body>
html>
location ~ ^/refer.html{
root html;
}
防盗链 就是 防止其他网站直接使用我们网站的图片等信息(例如这里,别人网站直接在img标签中加入我们图片的地址)
location ~ .*\.(jpg|gif|png)$ {
valid_referers none blocked 127.0.0.1;
if ($invalid_referer){
return 403;
}
root /opt/app/img;
}
正向代理
反向代理
配置语法
Syntax : proxy_pass URL;
# 请求到 Nginx 作为代理服务器后,去请求的URL
# 一般写成:http://localhost:8000/uri/
# https://182.168.1.1/uri/
# http://unix:/tmp/backend.socket:/uri/
Default : --
Context : location, if in location, limit_except
nginx.conf配置
location ~ /test_proxy.html$ {
proxy_pass http://127.0.0.1:8081;
# 外部访问80端口时,发送信息给本地8081端口
}
server {
listen 8081;
server_name localhost;
access_log /var/log/nginx/server.access.log main;
location / {
root /opr/app/code;
index index.html index.htm;
}
error_page 500 502 503 504 /50.html;
location = /50.html {
root html;
}
}
以上为 反向代理
http://nginx.org/en/docs/http/ngx_http_proxy_module.html
官方配置网址
配置缓冲区
Syntx : proxy_buffering on | off;
Default : proxy_buffering on;
Context : http, server, location
跳转重定向
Synatx : proxy_redirect default;
proxy_redirect off;
proxy_redirect redirect replacement;
Default : proxy_redirect default;
Context : htpp, server, location;
头信息
Syntax : proxy_set_header field value;
Default : proxy_set_header Host $proxy_host;
proxy_set_header Connection close;
Context : http, server, location;
还有 proxy_hide_header,proxy_set_body
超时
Syntax : proxy_connect_timeout time;
Default : proxy_connect_timeout 60s;
Context : http, server, location;
扩展:proxy_read_timeout,proxy_send_timeout
常用proxy的配置项
location / {
proxy_pass http:127.0.0.1:8089;
proxy_redirect default;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 32k;
proxy_buffering on;
proxy_buffers 4 128k;
proxy_busy_buffers_size 256k;
proxy_max_temp_file_size 256k;
}
我这就一台服务器,不学了,草!
proxy_cache配置语法
Syntax : proxy_cache_path path [levels=levels]
[use_temp_path=on|off] keys_zone=name:size[inactive=time]
[max_size=size][manager_files=number][manager_sleep=time]
[manager_threshold=time][lader_files=number]
[loader_sleep=time][loader_threshold=time][purger=on|off]
[purger_files=number][purger_sleep=time]
[purger_threshold=time];
Default : --
Context : http
Syntax : proxy_cache zone|off;
Default : proxy_cache off;
Context : http,server, location;
Syntax : proxy_cache_valid [code ...]time;
# code 对应返回状态码
Default : --
Context : http, server, location;
Syntax : proxy_cache_key string;
Default : proxy_cache_key $scheme$proxy_host$request_uri;
Context : http, server, location;
书写nginx.conf
proxy_cache_path /opt/app/cache levels=1:2 keys_zone=my_cache:10m inactive=60m use_temp_path=off;
server{
listen 80;
server_name localhose;
access_log /var/log/nginx/cache.access.log main;
location / {
proxy_cache my_cache;
proxy_pass 127.0.0.1;
proxy_cache_valid 200 304 12h;
proxy_cache_valid any 10m;
# 除了 200 403 外的状态码,10分钟过期
proxy_cache_key $host$uri$is_args$args;
add_header Nginx-Cache "$upstream_cache_status";
# 表示缓存是否命中
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
# 如果后端服务器 出现了不正常服务器,则不通过这台访问,去访问其他服务器
}
}
清理指定缓存
部分页面不缓存
Syntax : proxy_no_cache stirng ...;
Default : --
Context : http, server, location;
上述模块的写法
if ($request_uri ~ ^/(url3|login|register|password\/reset)){
set $cookie_nocache 1; # 如果请求地址以上述开头,则设置cookie_nocache为1
}
location / {
proxy_cache my_cache;
...#不重复写了
proxy_no_cache $cookie_nocache;# 如果为1,Nginx就不会缓存了
}
配置语法
Syntax : rewrite regex replacement [flag];
# regex 为正则表达式,用于匹配需要进行改写的url或者路径
# replacement 替换成目标或者哪一个路径
# flag 为一个标示
Default : --
Context : server, location, if
rewrite ^(.*)$ /pages/maintain.html break;
正则表达式
. | 匹配除换行符以外的任意字符 |
? | 重复0次或1次 |
+ | 重复1次或更多次 |
* | 最少连接数 |
\d | 匹配数字 |
^ | 匹配字符串的开头 |
$ | 匹配字符串的结尾 |
{n} | 重复n次 |
{n , } | 重复n次或更多次 |
[c] | 匹配单个字符c |
[a-z] | 匹配a-z的任意一个 |
() | 用于匹配括号之间的内容,通过$1,$2调用 |
if ($http_user_agent ~ MSIE){
rewrite ^(.*)$ /msie/$1 break;
}
上述的意思就是,匹配客户端的头信息是否有MSIE的内容
如果有,则提取出访问的内容,赋值给$1
rewrite中的flag
last | 停止rewrite检测,会新建请求,再按新链接请求一次服务端 |
break | 停止rewrite检测,会跳转去root目录查找 |
redirect | 返回302临时重定向,地址栏会显示跳转后的地址 |
last | 返回301永久重定向,地址栏会显示跳转后的地址 |