Serving pdf configuration issue

Victor Oppenheimer victor at camb.com
Wed Feb 7 19:21:09 UTC 2024


I am running nginx 1.24.0 on a computer with
Windows Server 2016 Server standard OS.

I am truing to use nginx to function as a reverse proxy
server when it received requests for some URLs and
to directly serve web pages for others.  I was successful s
configuing nginx to do the reverse proxy serving.

However, when I tried to directly serve some .pdf pages I kept
getting errors.  To isolate the problem I edited nginx.config
to only function as a direct server for a .pdf file.

I have a file named camprental.pdf in the directory
     C:\Users\victor\My 
Drive\Properties\rental_manuals_documents_and_email_templates\Clearwater

I want users to be able to browse to:
     www.clearwaterescapes.com/camp/camprental.pdf to see the file.

The nginx.conf file I am using to try to accomplish this is copied below.

When I start nginx with this config file and browse to:
     http://clearwaterescapes.com/camp/camprrental.pdf

I receive the following error message:
     This page isn’t working right nowclearwaterescapes.com redirected 
you too many times.

I assume that I am probably making a simple error.  But I do not see it.

Hopefully somebody will point it out.

--- Victor


The nginx.config file follows:
________________________________________________
# directives in the 'main' context
worker_processes auto;
events {    # events context/block
      # configuration of connection processing
             }

  http {    # http context specific to HTTP affecting all virtual servers
   server_names_hash_bucket_size 64;  # avoids error message for 
multiple server_Name entries

  server {
     listen 80;
     server_name clearwaterescapes.com;

        # Make incoming URLs lowercase
     rewrite ^(.*)$ /$1 permanent;

   # Rewrite rule for PDF files
   rewrite ^clearwaterescapes.com/camp/camprental.pdf$ 
http://www.clearwaterescapes.com/documentation/camprental.pdf break;

     # avoid errors when favicon.ico file is missing
     location = /favicon.ico {
         access_log off;
         log_not_found off;
         return 204;
     }

     location ~* ^/documentation/ {
         # Convert URL to lowercase and capture filename
         rewrite ^/documentation/(.*)$ /documentation/$1 break;

         # Serve documentation files directly
         root "C:/Users/victor/My 
Drive/Properties/rental_manuals_documents_and_email_templates/clearwater";
         try_files /$1 =404;
     }

     # Add location block for /camp/ requests
   location ~* ^/camp/ {
     root "C:/Users/victor/My 
Drive/Properties/rental_manuals_documents_and_email_templates/clearwater";
     try_files $uri =404;
}

     # Other server configuration...

}    # end of ClearwaterEscapes server block


      } # end of http block



More information about the nginx mailing list