-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathnginx.conf
126 lines (104 loc) · 3.31 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
if ($repositories ~ "^$") {
set $repositories "$ximera/repositories";
}
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/html application/html text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
# An git object is immutable
location ~ '^/[A-z0-9]+\.git/objects/[0-9a-f]{2}/[0-9a-f]{38}$' {
access_log off;
root $repositories;
add_header Cache-Control "public";
expires 1y;
}
# A pack file is immutable after creation
location ~ '^/[A-z0-9]+\.git/objects/pack/pack-[0-9a-f]{40}.(pack|idx)$' {
access_log off;
root $repositories;
add_header Cache-Control "public";
expires 1y;
}
# But information about packfiles is not...
location ~ '^/[A-z0-9]+\.git/objects/info/packs$' {
access_log off;
root $repositories;
add_header Cache-Control "no-cache";
}
# The HEAD ref could change.
location ~ '^/[A-z0-9]+\.git/HEAD$' {
access_log off;
root $repositories;
add_header Cache-Control "no-cache";
expires 1y;
}
# This is a bit annoying; nginx won't match on querystrings, so we
# use an unused code (419) to control flow. We can handle
# git-upload-pack and the "empty" git service with the dumb
# protocol, so let's do that. We reduce load on our node app, at
# the price of slower cloning.
location ~ '^(/[A-z0-9]+\.git/info/refs)$' {
error_page 419 = @gitUploadPack;
access_log off;
if ( $args ~ "service=git-upload-pack" ) { return 419; }
if ( $args = "" ) { return 419; }
# this is needed for the smart git protocol
client_max_body_size 0;
proxy_pass http://node;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering on;
}
location @gitUploadPack {
root $repositories;
add_header Cache-Control "no-cache";
access_log off;
}
location ^~ /public {
root $ximera;
access_log off;
add_header Cache-Control "public";
expires 1d;
location ~ '/public/v[0-9]+\.[0-9]+\.[0-9]+/(.*)$' {
root $ximera;
expires 1y;
try_files /public/$1 =404;
}
}
location ^~ /node_modules {
root $ximera;
access_log off;
add_header Cache-Control "public";
expires 1d;
location ~ '/node_modules/v[0-9]+\.[0-9]+\.[0-9]+/(.*)$' {
root $ximera;
expires 1y;
try_files /node_modules/$1 =404;
}
}
# send the request to our app server
location / {
proxy_pass http://node;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
# This is required for websockets to work?
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# Our node server can be slow, so buffering shold help
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}