title: Nginx server images only
body: <p>*******************************solved*****************************</p>
  
  <pre><code>    location ~ ^/images/(.+\.(?:gif|jpe?g|png))$
      {
              include /etc/nginx/mime.types;
              alias /site/$1;
  
      }
  </code></pre>
  
  <p>Not certain but I needed to add $1 to the end and changed the regex a little.  </p>
  
  <p>I have a route set up how do I only serve up png and jpg files.  Currently it serves up any extension.  </p>
  
  <pre><code> location /image {
       alias /site/;
   }
  </code></pre>
  
  <p>I've tired the following but received errors.</p>
  
  <pre><code>location /image \.(png|jpg)
  {
    alias /site/;
  }
  </code></pre>
  
  <p>I just want to show only png and jpg files in the directory.  Moving the files isn't an option. A lot of sub directories with images.  </p>
  
  <p>I've tried </p>
  
  <pre><code>location ~* ^/image/.+\.(png|jpg)$
  </code></pre>
  
  <p>I am getting no errors but the images aren't showing.  Yes the images are in the folder.  </p>
  
  <p>*********************** update *************************</p>
  
  <p>This location block works if I put a redirect in the block.  But if I try to show the image via 
  
  <pre><code>location ~* /images2/.+\.(png|jpg)$
  {
  }
  </code></pre>
  
  <p>The error logs says the following </p>
  
  <pre><code>GET /images2/flowers/type/T.png/ HTTP/1.1" 404 209
  </code></pre>