nginx_user10 Wrote:
-------------------------------------------------------
> nginx_user10 Wrote:
> -------------------------------------------------------
> > I am trying to serve images files only in this location block.
> >
> > location /image \.(png|jpg)
> > {
> > alias /site/;
> > }
> >
> > But I keep receiving errors. What is the correct way to serve only
> png
> > and jpg matching /images.
>
>
> *********************** update *************************
>
> This location block works if I put a redirect in the block. But if I
> try to show the image via <img src or make a link clickable nothing
> works.
>
> location ~* /images2/.+\.(png|jpg)$
> {
> }
>
> The error logs says the following
>
> GET /images2/flowers/type/T.png/ HTTP/1.1" 404 209
*******************************solved*****************************
location ~ ^/images/(.+\.(?:gif|jpe?g|png))$
{
include /etc/nginx/mime.types;
alias /site/$1;
}
Not certain but I needed to add $1 to the end and changed the regex a little.
-------------------------------------------------------
> nginx_user10 Wrote:
> -------------------------------------------------------
> > I am trying to serve images files only in this location block.
> >
> > location /image \.(png|jpg)
> > {
> > alias /site/;
> > }
> >
> > But I keep receiving errors. What is the correct way to serve only
> png
> > and jpg matching /images.
>
>
> *********************** update *************************
>
> This location block works if I put a redirect in the block. But if I
> try to show the image via <img src or make a link clickable nothing
> works.
>
> location ~* /images2/.+\.(png|jpg)$
> {
> }
>
> The error logs says the following
>
> GET /images2/flowers/type/T.png/ HTTP/1.1" 404 209
*******************************solved*****************************
location ~ ^/images/(.+\.(?:gif|jpe?g|png))$
{
include /etc/nginx/mime.types;
alias /site/$1;
}
Not certain but I needed to add $1 to the end and changed the regex a little.