forked from jholhewres/nginx-s3-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
80 lines (64 loc) · 2.4 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
worker_processes 2;
pid /run/nginx.pid;
daemon off;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
error_log /dev/stderr;
gzip on;
gzip_disable "msie6";
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
server {
listen 8000;
# Expire rules for static content
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
add_header Cache-Control "public";
rewrite /<PROXY_PATH_PREFIX GOES HERE>(.*) /$1 break;
proxy_pass <PROXY_PASS_HOST GOES HERE>/<BUCKET_NAME GOES HERE>/$1;
aws_access_key <ACCESS_KEY GOES HERE>;
aws_secret_key <SECRET_KEY GOES HERE>;
s3_bucket <BUCKET_NAME GOES HERE>;
proxy_set_header Authorization $s3_auth_token;
proxy_set_header Host <PROXY_HEADER_HOST GOES HERE>;
proxy_set_header x-amz-date $aws_date;
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 300;
add_header Cache-Control "public";
rewrite /<PROXY_PATH_PREFIX GOES HERE>(.*) /$1 break;
proxy_pass <PROXY_PASS_HOST GOES HERE>/<BUCKET_NAME GOES HERE>/$1;
aws_access_key <ACCESS_KEY GOES HERE>;
aws_secret_key <SECRET_KEY GOES HERE>;
s3_bucket <BUCKET_NAME GOES HERE>;
proxy_set_header Authorization $s3_auth_token;
proxy_set_header Host <PROXY_HEADER_HOST GOES HERE>;
proxy_set_header x-amz-date $aws_date;
}
# And, everything else
location ~ {
expires 300;
rewrite /<PROXY_PATH_PREFIX GOES HERE>(.*) /$1 break;
proxy_pass <PROXY_PASS_HOST GOES HERE>/<BUCKET_NAME GOES HERE>/$1;
aws_access_key <ACCESS_KEY GOES HERE>;
aws_secret_key <SECRET_KEY GOES HERE>;
s3_bucket <BUCKET_NAME GOES HERE>;
proxy_set_header Authorization $s3_auth_token;
proxy_set_header Host <PROXY_HEADER_HOST GOES HERE>;
proxy_set_header x-amz-date $aws_date;
}
}
}