LibreNMS .htaccess rewrite conversion

Hi,

I would like to migrate my LibreNMS installation to use Caddy instead of Apache/Nginx but right now I’m stuck with the .htaccess conversion. I already played around with it a bit but I’m not getting all LibreNMS functions (like generated Graphs) to work properly. Would be nice if someone could help me out with the conversion of the default .htaccess rewrite rules:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(js|ico|txt|gif|jpg|png|css|php)
RewriteRule ^api/v0(.*)$ api_v0.php/$1 [L]
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(js|ico|txt|gif|jpg|png|css|php)
RewriteRule ^(.*)$ index.php/$1/

This should (not tested) also be a working nginx rewrite file if that is easier to convert:

location @librenms {
  rewrite api/v0(.*)$ /api_v0.php/$1 last;
  rewrite ^(.+)$ /index.php/$1 last;
}

Would be nice to get your help on this!

Something like

example.com {
    rewrite {
        r api/v0(.*)
        to /api_v0.php?{1}
    }
    rewrite {
        r ^(.+)$
        to /index.php/{1}
    }
}

See docs for rewrite

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.