Serve ANSI, ASCII & BBS art
Below is a barebones configuration to serve plain text files using Nginx.
The location block applies the configuration only to files using the path http://example.com/ansi.
The served textfiles are in /var/www/example.com/html.
| nginx.conf | |
|---|---|
The types block further filter files to those utilising an .asc .ans or .txt file extension.
The charset "ISO-8859-1" directive combined with the types { text/plain } block adds a Content-Type:text/plain; charset=ISO-8859-1 response header.
It tells the browser to treat the file as plain text encoded as ISO-8859-1, a legacy character set RetroTxt can understand. You cannot use CP-437 or other DOS code pages as they are not valid browser encodings.
The add_header Content-Disposition "inline"; directive adds a Content-Disposition:inline response header that tells the browser to display the content in a tab.
The add_header X-Content-Type-Options "nosniff"; directive adds the X-Content-Type-Options:nosniff response header to tell browsers not to sniff the content.
MIME sniffing often inaccurately treats ANSI and other encoded text as binary files browsers download. Unfortunately, Firefox ignores this header request.