-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnginx.conf
More file actions
104 lines (85 loc) · 3.45 KB
/
nginx.conf
File metadata and controls
104 lines (85 loc) · 3.45 KB
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
load_module /usr/local/nginx/modules/ngx_http_fancyindex_module.so;
user nginx;
worker_processes 1;
error_log /dev/stderr warn;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
charset_types text/css text/plain application/javascript application/json;
log_format main '$http_x_forwarded_for - $remote_user [$time_local] '
'"$request_method $scheme://$host$request_uri '
'$server_protocol" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time';
access_log /dev/stdout main;
access_log /var/log/nginx/goaccess.log combined;
sendfile on;
#gzip on;
map $http_origin $is_good_origin {
~*([.|/]|^)mirrorz.org$ true;
~*(/|^)mirrors.cngi.edu.cn$ true;
~*(/|^)mirrors.cernet.edu.cn$ true;
~*(/|^)mirrors.edu.cn$ true;
~*([.|/]|^)test-cors.org$ false;
default false;
}
map $request_method $cors_method {
OPTIONS ${is_good_origin}_options;
GET ${is_good_origin}_get;
default ${is_good_origin}_other;
}
server {
listen 80;
server_name mirrors.scau.edu.cn;
root /mirrors/;
index index.html index.htm;
rewrite ^/(.*)$ https://$host/$1 permanent;
}
# HTTPS server
#
server {
listen 443 ssl;
server_name mirrors.scau.edu.cn;
ssl_certificate /ssl/mirrors.crt;
ssl_certificate_key /ssl/mirrors.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
root /mirrors/;
index index.html index.htm;
location /{
alias /Mirrors-Index/;
if ($cors_method = 'true_options') {
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Origin' '$http_origin';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-TUNA-MIRROR-ID';
add_header 'Vary' 'Origin';
add_header 'Access-Control-Max-Age' 604800; # a week
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($cors_method = 'true_get') {
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Origin' '$http_origin';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-TUNA-MIRROR-ID';
add_header 'Vary' 'Origin';
}
}
location ~ ^/(archlinux|centos|debian|debian-security|deepin|deepin-cd|epel|linuxmint-cd|openeuler|proxmox|raspbian|raspberrypi|termux|ubuntu|ubuntu-cdimage|ubuntukylin) {
fancyindex on;
fancyindex_exact_size on;
fancyindex_header "/fancy-header.html";
fancyindex_footer "/fancy-footer.html";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}