Nginx配置文件结构
Nginx配置文件(conf/nginx.conf)整体分为三部分:
- 全局块 和nginx运行相关的全局配置
- events块 和网络连接相关的配置
- http块 代理、缓存、日志记录、虚拟主机配置
- 注:http块中可以配置多个Server块,每个Server块可以配置多个locaiton块。
nginx.conf的默认内容如下:
# 全局块
worker_processes 2;
# events块
events {
worker_connections 1024;
}
# http块
http {
# http全局块
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# Server块
server {
# Server全局块
listen 80;
server_name localhost;
# location块
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}