Last active
August 19, 2016 19:37
-
-
Save eeevans/7c9318454ff802b08efc93130aaeeb1d to your computer and use it in GitHub Desktop.
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
server { | |
listen 80 default_server; | |
listen [::]:80 ipv6only=on default_server; | |
server_name gitlabsvr www.gitlabsvr; | |
root /var/www; | |
# Match the box name in location and search for its catalog | |
# e.g. http://www.example.com/vagrant/devops/ resolves /var/www/vagrant/devops/devops.json | |
location ~ ^/vagrant/([^\/]+)/$ { | |
index $1.json; | |
try_files $uri $uri/ $1.json =404; | |
autoindex off; | |
} | |
# Enable auto indexing for the folder with box files | |
location ~ ^/vagrant/([^\/]+)/boxes/$ { | |
try_files $uri $uri/ =404; | |
autoindex on; | |
autoindex_exact_size on; | |
autoindex_localtime on; | |
} | |
# Serve json files with content type header application/json | |
location ~ \.json$ { | |
add_header Content-Type application/json; | |
} | |
# Serve box files with content type application/octet-stream | |
location ~ \.box$ { | |
add_header Content-Type application/octet-stream; | |
} | |
# Deny access to document root and the vagrant folder | |
location ~ ^/(vagrant/)?$ { | |
return 403; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment