-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0770721
commit 811a8d1
Showing
3 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
daemon off; | ||
events { | ||
worker_connections 10240; | ||
accept_mutex on; | ||
} | ||
pid <%= root %>/nginx.pid; | ||
worker_rlimit_nofile 65535; | ||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
access_log <%= root %>/access.log; | ||
error_log stderr; | ||
|
||
map $arg_name $name { | ||
~.+ $arg_name; | ||
default $prefix; | ||
} | ||
|
||
server { | ||
listen <%= port %> default; | ||
root <%= root %>/cache; | ||
|
||
if ($uri ~ ^/download/(..)) { | ||
set $prefix $1; | ||
} | ||
|
||
location @be { | ||
proxy_pass http://localhost:<%= port+1 %>; | ||
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-Forwarded-Proto $scheme; | ||
} | ||
|
||
location ~ /download/(.*) { | ||
set $hash $1; | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
add_header x-bmclapi-hash $hash; | ||
try_files /$prefix/$hash @be; | ||
add_header content-disposition "attachment; filename=\"$arg_name\""; | ||
|
||
} | ||
|
||
location / { | ||
proxy_pass http://localhost:<%= port+1 %>; | ||
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-Forwarded-Proto $scheme; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters