Skip to content

NGINX configuration

Billy Charlton edited this page May 18, 2022 · 1 revision

The internal SimWrapper server is running NGINX, and we needed to make some changes to the config to get everything working -- specifically, getting single-page app URLs to map to the correct pages, and disabling caching on the Windows file storage so that changes to files are immediately picked up on reload.

  • All of these changes happen on the config file /etc/nginx/sites-enabled/default

  • The content below belongs inside the top level server {} section. You may have other stuff in there already

server {
  # ...
  # you already have a server section
  # ...

  location / {
   try_files $uri $uri/ =404;
  }

  location /champ_runs/ {
    # Enable CORS and range requests for partial file downloads
    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Allow-Headers "Accept-Ranges,Range,*";
    add_header Accept-Ranges "bytes";
    autoindex on;

    # kill cache for the champ_runs windows share
    add-header Last-Modified $date_gmt;
    add-header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
    add-header Pragma 'no-cache';
    if_modified_since_off;
    expires 0;
    etag off;
  }

  location /simwrapper/ {
    # Redirect long URLs to the app index file which will handle them correctly
    try_files $uri $uri/ /simwrapper/index.html;
  }

# end server section
}
Clone this wiki locally