server_name _;

root /mirror/root;
index index.html;
autoindex on;
autoindex_exact_size off;

location / {
  # First attempt to serve request as file, then
  # as directory, then fall back to displaying a 404.
  try_files $uri $uri/ =404;
}

# Server status
location /server-status {
  stub_status on;
#   allow 127.0.0.1;
#   allow ::1;
#   allow 129.97.134.0/24;
#   allow 129.97.31.128/26;
#   allow 2620:101:f000:4901::/64;
#   allow 2620:101:f000:4902::/64;
#   deny all;
}

# Statistics
location ~ /stats/(?<ndpath>.*) {
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass http://[::1]:19999/$ndpath$is_args$args;
  proxy_http_version 1.1;
  proxy_pass_request_headers on;
  proxy_set_header Connection "keep-alive";
  proxy_store off;
}

location = /stats {
  return 301 /stats/;
}

# On behalf of WiCS, redirect all files
# from sarah_sharp to sage_sharp
location ~ /wics/sarah_sharp_(?<file>.*) {
  return 301 /wics/sage_sharp_$file;
}

# Ceph has a special access log
location /ceph {
  access_log /var/log/nginx/access.ceph.log;
}

# Removed projects
location ^~ /kali {return 410;}
location ^~ /kali-images {return 410;}
location ^~ /hyperbola {return 410;}
