[Tips] Fix new subdirectories for web page not available

Raspberry Pi related support

[Tips] Fix new subdirectories for web page not available

Postby rern » 27 Jul 2017, 11:27

[Tips] Fix new subdirectories for web page not available
(RuneAudio 20160313)

For those who want to add some additional webpages in new subdirectories.

The existing configuration of NGINX web server redirects all requests of certain file types to /srv/http/assets/.
Any files of those types in other subdirectories will never be reached.

The lines that cause it:
/etc/nginx/nginx.conf
Code: Select all
   # rewrite RULES
   rewrite /css/(.*) /assets/css/$1 break;
   rewrite /less/(.*) /assets/less/$1 break;
   rewrite /js/(.*) /assets/js/$1 break;
   rewrite /img/(.*) /assets/img/$1 break;
   rewrite /fonts/(.*) /assets/fonts/$1 break;
They were set as global rules.

Fix: Make the rules specific for root directory by move those lines inside:
Code: Select all
    server {
        listen 80 deferred;
        add_header X-UA-Compatible "IE=Edge,chrome=1";
        access_log  /var/log/runeaudio/runeui_access.log;
        location / {
            root   /var/www;
            index  index.php index.html index.htm;
            try_files       $uri /index.php;

            ### MOVE HERE ###
        }
        ...


After systemctl restart nginx, all subdirectories will be reachable as they shoud be.
rAudio @ https://github.com/rern/rAudio-1
Raspberry Pi 4B
Raspberry Pi 3B > SMSL M8 DAC
Raspberry Pi Zero W
User avatar
rern
 
Posts: 723
Joined: 14 Jul 2016, 08:15

support RuneAudio Donate with PayPal

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 6 guests