-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
46 lines (40 loc) · 1.81 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
# nginx -c /code/nginx.conf -g 'daemon off;'
# serveless的nginx配置有点奇怪,gzip不能关闭,gzip_static可以开启,源文件也需要上传,优先使用静态的.gz,没有就动态压缩,不符合压缩标准的采用源文件
events { worker_connections 1024; }
http {
gzip off; # 是否开启动态压缩
gzip_static on; #是否开启静态压缩,默认后缀为.gz
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/html text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png image/svg+xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
server {
error_log /dev/stderr;
access_log /dev/stdout;
include /etc/nginx/mime.types;
listen 9000;
location / {
root /code;
index index.html;
add_header Cache-Control "max-age=0";
try_files $uri $uri/ /index.html =404;
# 跨域配置
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
}
}
}