diff --git a/.conf/dps_27/lighttpd.tasmoadmin.3.conf b/.conf/dps_27/lighttpd.tasmoadmin.3.conf new file mode 100644 index 0000000000..f69c58c72a --- /dev/null +++ b/.conf/dps_27/lighttpd.tasmoadmin.3.conf @@ -0,0 +1,14 @@ +$HTTP["url"] =~ "^/tasmoadmin($|/)" { + # Deny direct access to .htaccess and data directory + $HTTP["url"] =~ "^/tasmoadmin/(\.|data)" { + # Allow direct access to firmwares + $HTTP["url"] !~ "^/tasmoadmin/data/firmwares" { + url.access-deny = ("") + } + } + + # TasmoAdmin URL rewrites + else $HTTP["url"] !~ "^/tasmoadmin/index\.php($|/)" { + url.rewrite-if-not-file = ("^/tasmoadmin/(.*)$" => "/tasmoadmin/index.php?$1") + } +} diff --git a/.conf/dps_27/lighttpd.tasmoadmin.conf b/.conf/dps_27/lighttpd.tasmoadmin.conf index b63f338d83..97e7fc2f39 100644 --- a/.conf/dps_27/lighttpd.tasmoadmin.conf +++ b/.conf/dps_27/lighttpd.tasmoadmin.conf @@ -7,7 +7,7 @@ $HTTP["url"] =~ "^/tasmoadmin($|/)" { } } - # TasmoAdmin URL rewrites required for sync clients + # TasmoAdmin URL rewrites url.rewrite-if-not-file = ( "^/tasmoadmin/doAjax$" => "/tasmoadmin/index.php?doAjax=doAjax", "^/tasmoadmin/doAjaxAll$" => "/tasmoadmin/index.php?doAjaxAll=doAjaxAll", diff --git a/.conf/dps_27/nginx.tasmoadmin.3.conf b/.conf/dps_27/nginx.tasmoadmin.3.conf new file mode 100644 index 0000000000..4de7963cbd --- /dev/null +++ b/.conf/dps_27/nginx.tasmoadmin.3.conf @@ -0,0 +1,30 @@ +# Location: /etc/nginx/sites-dietpi/dietpi-tasmoadmin.conf +# Based on: https://github.com/TasmoAdmin/TasmoAdmin/blob/master/.docker/rootfs/etc/nginx/nginx.conf +location ^~ /tasmoadmin { + # Allow direct access to firmwares + location ^~ /tasmoadmin/data/firmwares { + add_header Access-Control-Allow-Origin *; + } + + # Deny direct access to .htaccess and data directory + location ~ ^/tasmoadmin/(?:\.|data) { + deny all; + } + + location ~ ^/tasmoadmin/index\.php(/|$) { + fastcgi_pass php; + fastcgi_read_timeout 900; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + internal; + } + + location ~ \.(css|js|gif||jpe?g|png|json|cache\.json)$ { + } + + location /tasmoadmin { + try_files $uri $uri/ /tasmoadmin/index.php$is_args$args; + } +} diff --git a/.conf/dps_27/nginx.tasmoadmin.conf b/.conf/dps_27/nginx.tasmoadmin.conf index 62fca0f85d..d501014b27 100644 --- a/.conf/dps_27/nginx.tasmoadmin.conf +++ b/.conf/dps_27/nginx.tasmoadmin.conf @@ -1,6 +1,9 @@ +# Location: /etc/nginx/sites-dietpi/dietpi-tasmoadmin.conf +# Based on: https://github.com/TasmoAdmin/TasmoAdmin/blob/v2.4.2/.docker/rootfs/etc/nginx/nginx.conf location ^~ /tasmoadmin { # Allow direct access to firmwares location ^~ /tasmoadmin/data/firmwares { + add_header Access-Control-Allow-Origin *; } # Deny direct access to .htaccess and data directory @@ -8,7 +11,7 @@ location ^~ /tasmoadmin { deny all; } - location ~* \.php$ { + location ~ \.php$ { fastcgi_pass php; fastcgi_read_timeout 900; fastcgi_split_path_info ^(.+\.php)(/.+)$; @@ -17,10 +20,10 @@ location ^~ /tasmoadmin { include fastcgi_params; } - location ~* \.(css|js|gif||jpe?g|png|json|cache\.json)$ { + location ~ \.(css|js|gif||jpe?g|png|json|cache\.json)$ { } - # TasmoAdmin URL rewrites required for sync clients + # TasmoAdmin URL rewrites location /tasmoadmin { rewrite ^/tasmoadmin/login$ /tasmoadmin/login.php last; rewrite ^/tasmoadmin/logout$ /tasmoadmin/login.php?logout=logout last; diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7b118ec3e9..d3b7d42654 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -13,6 +13,7 @@ Bug fixes: - DietPi-LetsEncrypt | Resolved a v8.20 regression where Lighttpd did not start after applying or renewing the certificate due to a syntax error. Many thanks to @JappeHallunken for fixing this issue: https://github.com/MichaIng/DietPi/pull/6517 - DietPi-Config | Resolved an issue where /etc/network/interfaces was created with missing key values if lines were previously manually removed. Defaults are now applied in this case. Many thanks to @huettenwirt for reporting this issue: https://dietpi.com/forum/t/ifup-error-due-to-faulty-etc-network-interfaces/17605 - DietPi-Config | Resolved an issue where the DHCP server failed to start after applying WiFi hotspot settings. +- DietPi-Software | TasmoAdmin: Resolved an issue on Bookworm systems with Nginx and Lighttpd webserver where login and logout did not work anymore as the rewrite directives pointed to a file which does not exist anymore since TasmoAdmin v3. Many thanks to @TBirth for reporting this issue: https://dietpi.com/forum/t/tasmoadmin-not-found-after-visiting-login-page/17632 As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/MichaIng/DietPi/pull/XXXX diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index ebbedb6a86..b0460d0c95 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -11185,8 +11185,10 @@ _EOF_ if To_Install 27 # TasmoAdmin then - # Install required PHP modules - aDEPS=("php$PHP_VERSION-curl" "php$PHP_VERSION-zip") # https://github.com/reloxx13/TasmoAdmin#linux + # Install required PHP modules: https://github.com/TasmoAdmin/TasmoAdmin/wiki/Guide-for-Debian-Server-10-(Buster) + aDEPS=("php$PHP_VERSION-curl" "php$PHP_VERSION-zip") + (( $G_DISTRO > 5 )) && aDEPS+=("php$PHP_VERSION-mbstring" "php$PHP_VERSION-xml") + local adeps=("${aDEPS[@]#*-}") # Reinstall: Skip download and install, advice to use internal updater from web UI if [[ -d '/var/www/tasmoadmin' ]] @@ -11216,9 +11218,13 @@ _EOF_ fi # Webserver config + # - Config file Version + local version= + (( $G_DISTRO > 6 )) version='.3' if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )) then G_DIETPI-NOTIFY 2 'Apache webserver found, enabling TasmoAdmin specific configuration.' + G_EXEC a2enmod setenvif rewrite authz_core authn_core authn_file local tasmoadmin_conf='/etc/apache2/sites-available/dietpi-tasmoadmin.conf' if [[ -f $tasmoadmin_conf ]] then @@ -11226,8 +11232,7 @@ _EOF_ G_WHIP_MSG "Existing TasmoAdmin Apache configuration found, will preserve the old one and save the new one for review and comparison to: $tasmoadmin_conf" fi dps_index=$software_id Download_Install 'apache.tasmoadmin.conf' "$tasmoadmin_conf" - a2enmod setenvif rewrite authz_core authn_core authn_file 1> /dev/null - a2ensite dietpi-tasmoadmin 1> /dev/null + G_EXEC a2ensite dietpi-tasmoadmin elif (( ${aSOFTWARE_INSTALL_STATE[84]} > 0 )) then @@ -11238,7 +11243,7 @@ _EOF_ tasmoadmin_conf+='.dietpi-new' G_WHIP_MSG "Existing TasmoAdmin Lighttpd configuration found, will preserve the old one and save the new one for review and comparison to: $tasmoadmin_conf" fi - dps_index=$software_id Download_Install 'lighttpd.tasmoadmin.conf' "$tasmoadmin_conf" + dps_index=$software_id Download_Install "lighttpd.tasmoadmin$version.conf" "$tasmoadmin_conf" G_EXEC_POST_FUNC(){ [[ $exit_code == 2 ]] && exit_code=0; } # Do not fail if modules are enabled already G_EXEC lighty-enable-mod rewrite dietpi-tasmoadmin @@ -11251,8 +11256,11 @@ _EOF_ owncloud_conf+='.dietpi-new' G_WHIP_MSG "Existing TasmoAdmin Nginx configuration found, will preserve the old one and save the new one for review and comparison to: $tasmoadmin_conf" fi - dps_index=$software_id Download_Install 'nginx.tasmoadmin.conf' "$tasmoadmin_conf" + dps_index=$software_id Download_Install "nginx.tasmoadmin$version.conf" "$tasmoadmin_conf" fi + + # Enable required PHP modules + G_EXEC phpenmod "${adeps[@]}" fi if To_Install 206 openhab # openHAB