Skip to content

Instantly share code, notes, and snippets.

@danvk
Created December 14, 2015 21:25
Show Gist options
  • Save danvk/b285395af6512e4e8ac1 to your computer and use it in GitHub Desktop.
Save danvk/b285395af6512e4e8ac1 to your computer and use it in GitHub Desktop.
server {
listen 9876;
access_log /var/log/hdfs-fuse/access.log;
error_log /var/log/hdfs-fuse/error.log;
location /hpc {
deny all;
location ~ "\.(bam|vcf|bai|maf|gz|tab|fpkm_tracking)$" {
allow all;
}
root /; # /hpc comes from the request
expires 1M; # Cache everything for 1 month
# CORS support
# add_header Cache-Control "public";
add_header Accept-Ranges bytes;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Range,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
# add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Allow-Methods' 'HEAD, GET, OPTIONS';
add_header 'Access-Control-Max-Age' 1728000; # cache for 20 days
add_header Last-Modified "";
if ($request_method = 'OPTIONS') {
# CORS preflight
# add_header 'Content-Type' 'text/plain';
return 200;
}
# Enabling gzip disables support for range requests.
# It should be possible (and desirable!) to enable it for non-range requests.
# TODO: octet-stream is too general; BAM makes no sense to compress.
gzip_types text/plain application/octet-stream;
gzip on;
if ($http_range) {
gzip off;
}
}
location /demeter {
deny all;
location ~ "\.(bam|vcf|bai|maf|gz|tab|fpkm_tracking)$" {
allow all;
}
root /; # /demeter comes from the request
expires 1M; # Cache everything for 1 month
# CORS support
# add_header Cache-Control "public";
add_header Accept-Ranges bytes;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Range,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
# add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Allow-Methods' 'HEAD, GET, OPTIONS';
add_header 'Access-Control-Max-Age' 1728000; # cache for 20 days
add_header Last-Modified "";
if ($request_method = 'OPTIONS') {
# CORS preflight
# add_header 'Content-Type' 'text/plain';
return 200;
}
# Enabling gzip disables support for range requests.
# It should be possible (and desirable!) to enable it for non-range requests.
# TODO: octet-stream is too general; BAM makes no sense to compress.
gzip_types text/plain application/octet-stream;
gzip on;
if ($http_range) {
gzip off;
}
}
location / {
root /hdfs;
expires 1M; # Cache everything for 1 month
# CORS support
# add_header Cache-Control "public";
add_header Accept-Ranges bytes;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Range,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
# add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Allow-Methods' 'HEAD, GET, OPTIONS';
add_header 'Access-Control-Max-Age' 1728000; # cache for 20 days
add_header Last-Modified "";
if ($request_method = 'OPTIONS') {
# CORS preflight
# add_header 'Content-Type' 'text/plain';
return 200;
}
# Enabling gzip disables support for range requests.
# It should be possible (and desirable!) to enable it for non-range requests.
# TODO: octet-stream is too general; BAM makes no sense to compress.
gzip_types text/plain application/octet-stream;
gzip on;
if ($http_range) {
gzip off;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment