blob: 1eaadc9954a85e7109a1e1cbf74253e4435e4842 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
map $http_user_agent $format_suffix {
"~*curl" ".txt";
"~*wget" ".txt";
default "";
}
# Also check for Accept: text/plain
map $http_accept $final_suffix {
"~*text/plain" ".txt";
default $format_suffix;
}
server {
listen 80;
server_name jayrup.me;
root /usr/share/nginx/html;
location / {
# This handles:
# 1. /cv -> /cv.txt (for curl)
# 2. /cv -> /cv.html (for browser)
# 3. /projects/ -> /projects/index.txt (for curl)
try_files $uri$final_suffix $uri.html $uri/index$final_suffix $uri/index.html =404;
}
# Ensure text files are served correctly
location ~* \.txt$ {
add_header Content-Type text/plain;
}
}
|