I´m trying to serve a pdf file by making a configuration in nginx but I get the following error in the page: 404 Not Found
The configuration is like this:
server {
listen 3002;
index index.html;
server_name _;
location / {
root /var/www/html/pdf_carpet;
try_files $uri /index.html = 404;
}
}
pdf_carpet is where the pdf file is.
What could I do or change to be able to serve a pdf file in nginx?
P.S. It works with html files.
location = / { ... }.try_filesdirective in the answer I'm referring to? Remove it. And how are you trying to access the file? With the config you show in your last comment (without thetry_filesdirective) your PDF file should be accessible with thehttp://<your_domain_or_IP>:3002/pdf_carpetURL.default_type application/pdf;directive to that location.