Search code examples
pdfnginxlocation

Serve pdf file by location in nginx


How I can to serve the file:

'/webapps/app/static/downloads/privacy_policy.pdf'

by address:

https://my.site.net/privacy/

I try to use location in my nginx, but this not work:

location /privacy/ {
   alias /webapps/app/static/downloads/privacy_policy.pdf;
}

Solution

  • I found solution. I move the pdf file in separate directory "privacy". I set the directory as alias and set I set pdf document as an index file:

    location /privacy/ {
       alias /webapps/app/static/downloads/privacy/;
       index privacy_policy.pdf;
    }