Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

nginx setup #49

Open
jimdi opened this issue May 24, 2018 · 1 comment
Open

nginx setup #49

jimdi opened this issue May 24, 2018 · 1 comment

Comments

@jimdi
Copy link

jimdi commented May 24, 2018

here sample for nginx config

       autoindex on;
       location / {
                try_files $uri $uri/ =404;
                rewrite ^/?$ /viewer.php;
                rewrite ^/([^/\.]+).gif/?$ /viewer.php?type=gif&file=$1;
                rewrite ^/([^/\.]+)(.jpg|.jpeg)/?$ /viewer.php?type=jpeg&file=$1;
                rewrite ^/([^/\.]+)(.png)?/?$ /viewer.php?type=png&file=$1;
        }
        location /g {
                rewrite ^/g/([^/\.]+)(.gif)?/?$ /viewer.php?type=gif&file=$1;
        }

        location /j {
                rewrite ^/j/([^/\.]+)(.jpg|.jpeg)?/?$ /viewer.php?type=jpeg&file=$1;
        }

        location /w {
                rewrite ^/w/([^/\.]+)(.webm)?/?$ /viewer.php?type=webm&file=$1;
        }

@ayubun
Copy link

ayubun commented Mar 5, 2021

I think the above config breaks if the filename begins with a g, j, or w.

This should fix the bug from occurring, by declaring the location blocks to only resolve on the directories g, j, and w (as opposed to any URL that starts with g, j, or w):

autoindex on;
location / {
         try_files $uri $uri/ =404;
         rewrite ^/?$ /viewer.php;
         rewrite ^/([^/\.]+).gif/?$ /viewer.php?type=gif&file=$1;
         rewrite ^/([^/\.]+)(.jpg|.jpeg)/?$ /viewer.php?type=jpeg&file=$1;
         rewrite ^/([^/\.]+)(.png)?/?$ /viewer.php?type=png&file=$1;
 }

 location /g/ {
         rewrite ^/g/([^/\.]+)(.gif)?/?$ /viewer.php?type=gif&file=$1;
 }

 location /j/ {
         rewrite ^/j/([^/\.]+)(.jpg|.jpeg)?/?$ /viewer.php?type=jpeg&file=$1;
 }

 location /w/ {
         rewrite ^/w/([^/\.]+)(.webm)?/?$ /viewer.php?type=webm&file=$1;
 }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants