-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
51 lines (42 loc) · 1.16 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 全局配置
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
# 事件模块配置
events {
use epoll; # 多路复用
worker_connections 1024;
}
# HTTP模块配置
http {
# MIME类型配置
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"';
# 访问日志配置
access_log /var/log/nginx/access.log main;
# Gzip压缩配置
gzip on;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# 服务器配置
server {
listen 80;
server_name localhost;
# 根目录配置
root /usr/share/nginx/html;
index index.html;
# 其他路由配置
location / {
try_files $uri $uri/ /index.html;
}
# 静态文件缓存配置
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1d;
}
}
}