> For the complete documentation index, see [llms.txt](https://yangsx95.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yangsx95.gitbook.io/notes/distributed/web-fu-wu-qi/nginx/fu-lu.md).

# 附录

## 附录〇：参考资料

**官方文档：**

* [Module ngx\_http\_rewrite\_module](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html)

**其他：**

* [linux环境下安装nginx步骤](https://www.cnblogs.com/wyd168/p/6636529.html)
* [nginx之location的匹配规则](https://www.cnblogs.com/jiangyang/p/8485046.html)
* [Nginx Rewrite详解](https://www.cnblogs.com/dami520/archive/2012/08/16/2642967.html)
* [知乎：罗志宇 IO 多路复用是什么意思？](https://www.zhihu.com/question/32163005/answer/55772739)
* [nginx sendfile tcp\_nopush tcp\_nodelay参数解释](https://blog.csdn.net/zmj_88888888/article/details/9169227)
* [http协议缓存机制](https://juejin.im/entry/5993dabd518825244630ea2a)
* [Nginx服务状态监控](https://www.cnblogs.com/kongzhongqijing/articles/7482867.html)

## 附录一：nginx内置变量

官方文档：<http://nginx.org/en/docs/http/ngx\\_http\\_log\\_module.html#access\\_log>

```nginx
# 请求的公共信息（包含主机名称 地址路径等）
# 请求地址的主机名称，域名或者ip+端口，比如请求 localhost/path/path1?aa=bb&bb=cc 返回host
$http_host
# 请求首行，例如 GET /path?aa=bb&bb=cc HTTP/1.1
$request
# 请求方法, 返回为GET、POST、DELETE等
$request_method
# 请求uri，比如 /path?aa=bb&bb=cc
$request_uri
# 请求uri 不含参数，比如 /path
$uri / $document_uri
# 获取请求参数(url参数)，不含问号 比如 aa=bb&bb=cc
$args / $query_string
# 获取指定请求参数，比如获取请求参数aa的值， 返回为bb，如果不存在此参数，则返回空字符串
$arg_NAME
$arg_aa
# 判断请求参数是否存在, 如果存在，则返回 ? 否则返回空字符串
$is_args

# 获取名称为NAME的请求头的值，比如获取Accept-Language头的值可以写为：$http_accept_language
$http_NAME 
$http_accept_language
# 以下是常用的头信息
$http_referer # referer url跳转来源,用来记录从那个页面链接访问过来的，常用于防盗链、用户行为分析
$http_user_agent #用户终端浏览器等信息
$http_cookie # cookie
# 获取cookie中的值，name代表key名称，不存在返回空字符串
$cookie_NAME
#"Content-Type" 请求头字段
$content_type     
#"Content-Length" 请求头字段
$content_length
# 记录每一级http请求所携带的信息
http_x_forwared_for

#客户端的请求主体：此变量可在location中使用，将请求主体通过proxy_pass，fastcgi_pass，uwsgi_pass和scgi_pass传递给下一级的代理服务器
$request_body
#将客户端请求主体保存在临时文件中。文件处理结束后，此文件需删除。如果需要之一开启此功能，需要设置client_body_in_file_only。如果将次文件传 递给后端的代理服务器，需要禁用request body，即设置proxy_pass_request_body off，fastcgi_pass_request_body off，uwsgi_pass_request_body off，or scgi_pass_request_body off
$request_body_file
# 服务端相应给客户端的body信息的大小
$body_bytes_sent 


# 响应
# 用于设置或者查询响应状态
$status
# 用于设置或者查询响应头字段，比如$sent_http_content_length
$sent_http_NAME
$sent_http_cache_control
$sent_http_connection
$sent_http_content_type
$sent_http_keep_alive
$sent_http_last_modified
$sent_http_location
$sent_http_transfer_encoding

# 客户端信息
#客户端ip地址
$remote_addr
#客户端地址的二进制形式，固定长度为4个字节 (常用，节省空间)
$binary_remote_addr
#客户端端口
$remote_port      

$document_root           #当前请求的文档根目录或别名
$host                    #优先级：HTTP请求行的主机名>"HOST"请求头字段>符合请求的服务器名.请求中的主机头字段，如果请求中的主机头不可用，则为服务器处理请求的服务器名称
$hostname                #主机名
$https                   #如果开启了SSL安全模式，值为"on"，否则为空字符串。
$body_bytes_sent         #传输给客户端的字节数，响应头不计算在内；这个变量和Apache的mod_log_config模块中的"%B"参数保持兼容
$bytes_sent              #传输给客户端的字节数
$connection              #TCP连接的序列号
$connection_requests     #TCP连接当前的请求数量
          

$cookie_name             #cookie名称
$limit_rate              #用于设置响应的速度限制
$msec                    #当前的Unix时间戳
$nginx_version           #nginx版本
$pid                     #工作进程的PID
$pipe                    #如果请求来自管道通信，值为"p"，否则为"."
$proxy_protocol_addr     #获取代理访问服务器的客户端地址，如果是直接访问，该值为空字符串
$realpath_root           #当前请求的文档根目录或别名的真实路径，会将所有符号连接转换为真实路径

$remote_user             #用于HTTP基础认证服务的用户名


$request_completion      #如果请求成功，值为"OK"，如果请求未完成或者请求不是一个范围请求的最后一部分，则为空
$request_filename        #当前连接请求的文件路径，由root或alias指令与URI请求生成
$request_length          #请求的长度 (包括请求的地址，http请求头和请求主体)
$request_time            #处理客户端请求使用的时间,单位为秒，精度毫秒； 从读入客户端的第一个字节开始，直到把最后一个字符发送给客户端后进行日志写入为止。
$scheme                  #请求使用的Web协议，"http" 或 "https"
$server_addr             #服务器端地址，需要注意的是：为了避免访问linux系统内核，应将ip地址提前设置在配置文件中
$server_name             #服务器名
$server_port             #服务器端口
$server_protocol         #服务器的HTTP版本，通常为 "HTTP/1.0" 或 "HTTP/1.1"

$time_iso8601            #服务器时间的ISO 8610格式
$time_local              #服务器时间（LOG Format 格式）

```

## 附录二：常见问题解决方案

* [解决Nginx出现403 forbidden (13: Permission denied)报错的四种方法](https://blog.csdn.net/onlysunnyboy/article/details/75270533)

  注：将目录设置在`/root`下，无论文件夹是否被赋予权限，始终会出现此错误（原因暂时不明）。
