Serve pdf file by location in nginx

Ponzio Pilato asked:

I’d like to serve a unique pdf file by location in nginx.

I followed the instruction here:

and I did:

location /xxx-privacy-disclosure/ {
    alias /var/www/public_html/;
    index xxx-privacy-disclosure.pdf;

Everything is working except
a .pdf file is downloaded (without the filename)

How can I fix this?

My answer:

Drop the index directive and replace it with, e.g. return 302 to make a redirect.

location /xxx-privacy-disclosure/ {
    alias /var/www/public_html/;
    return 302 xxx-privacy-disclosure.pdf;

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.