-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathnginx.conf
139 lines (107 loc) · 3.79 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
user root;
worker_processes auto;
worker_cpu_affinity auto;
pid /usr/app/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
# reuse_port on;
multi_accept on;
worker_connections 65535;
}
http {
fastcgi_intercept_errors on;
server_tokens off;
proxy_ignore_client_abort on;
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"';
# 如果使用了 docker,记得挂在到宿主机器以便查看日志
access_log /var/log/nginx/access.log main;
# 如果使用了 docker,记得挂在到宿主机器以便查看日志
error_log /var/log/nginx/error.log;
sendfile on;
tcp_nodelay on;
tcp_nopush on;
server_names_hash_bucket_size 512;
types_hash_max_size 2048;
client_header_buffer_size 128k;
large_client_header_buffers 4 512k;
client_max_body_size 50m;
send_timeout 2m;
client_header_timeout 5m;
client_body_timeout 5m;
keepalive_timeout 3s;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
#gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
gzip_types text/plain text/css text/javascript application/javascript application/x-javascript application/xml image/gif image/jpeg image/png image/x-icon image/x-ms-bmp;
gzip_vary on;
##local_cache##
#slowfs_cache_path /dev/shm/nginx_cache/local_cache_dir levels=1:2 keys_zone=localcache:512m inactive=30d max_size=1g;
#slowfs_temp_path /dev/shm/nginx_cache/local_temp_dir 1 2;
####
##cache##
#proxy_cache_path /dev/shm/nginx_cache/proxy_cache_dir levels=1:2 keys_zone=proxycache:512m inactive=30d max_size=1g;
#proxy_temp_path /dev/shm/nginx_cache/proxy_temp_dir;
client_body_buffer_size 512k;
proxy_connect_timeout 60;
proxy_read_timeout 120;
proxy_send_timeout 30;
proxy_buffer_size 512k;
proxy_buffers 16 512k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 512k;
# proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_next_upstream error timeout ;
##end##
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
######### ssl ##################
ssl_session_cache shared:SSL:1024m;
ssl_session_timeout 10m;
#ssl_session_tickets on;
#ssl_stapling on;
#ssl_stapling_verify on;
#resolver 114.114.114.114 valid=300s;
#resolver_timeout 5s;
#ssl_trusted_certificate /sslkey/ocsp/ca.pem;
#ssl_stapling_file /sslkey/ocsp/banksteel.ocsp;
server {
listen 80;
server_name lx.doc.cn;
location / {
root /usr/web/html/lx-doc/;
index index.html;
try_files $uri $uri/ /index.html;
}
location ~ ^/(.+)/(\d+)(/)*$ {
set $path_part $1; # 将第一个捕获组(路径部分)存储在变量中
root /usr/web/html/lx-doc/;
index index.html;
try_files $path_part $path_part/ /$path_part/index.html;
}
location /static/ {
alias /usr/attament/lx-doc/;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api {
#add_header Cache-Control 'no-store';
proxy_pass http://127.0.0.1:9222;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}