summaryrefslogtreecommitdiff
path: root/nginx.conf
blob: c8668c0f312dbe8e8ab87280b878084bfcfacb6e (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
map $http_user_agent $format_suffix {
    "~*curl"  ".txt";
    "~*wget"  ".txt";
    default   "";
}

map $http_accept $final_suffix {
    "~*text/plain" ".txt";
    default        $format_suffix;
}

server {
    listen 80;
    server_name jayrup.me;
    root /usr/share/nginx/html;

    # Serve PDFs directly
    location ~* \.pdf$ {
        add_header Content-Type application/pdf;
        add_header Content-Disposition inline;
        try_files $uri =404;
    }

    # /cv should point to the PDF
    location = /cv {
    try_files
        /cv$final_suffix
        /cv/index$final_suffix
        /cv.pdf
        =404;
    }

    # /dissertation serves summary page or PDF fallback
    location = /dissertation {
        try_files
            /projects/dis/index$final_suffix
            /projects/dis/index.html
            /projects/dis$final_suffix
            /dissertation.pdf
            =404;
    }


    location / {
        try_files
            $uri$final_suffix
            $uri.html
            $uri/index$final_suffix
            $uri/index.html
            =404;
    }

    location ~* \.txt$ {
        add_header Content-Type text/plain;
    }
}