froxlor / Froxlor

The server administration software for your needs - The official Froxlor development Git repository
http://www.froxlor.org
GNU General Public License v2.0
1.63k stars 453 forks source link

Nginx Location /{ not work #1185

Closed drexlma closed 1 year ago

drexlma commented 1 year ago

$vhost = preg_replace("/^(\s+)location(.+){(.+)}$/misU", "location $2 {\n $3 \n}", $vhost);

Nach der Änderung der letzten version dieser Zeile funktioniert der location /{ xxx} Eintrag nicht mehr. Nur noch wenn ein Leerzeichen zwischen / und { ist.

das müsste das der Grund sein. https://github.com/Froxlor/Froxlor/compare/2.0.21...2.0.23#diff-dc8225dcb1b695c0419c8b3603474f839ceab27a7cfc276abc31b15c3ba1c3c2R886

d00p commented 1 year ago

Was heisst denn "funktioniert nicht", bitte Fehlermeldungen mitgeben, wo du was genau eingetragen hast etc.pp.

drexlma commented 1 year ago

naja du fügst dann den location pfad bei nginx hinzu so das er dann zweimal ist weil er den in der spezialsetting nicht erkennt

Fehlermeldung: nginx: [emerg] duplicate location "/"

d00p commented 1 year ago

gib doch mal bitte genau an welche inhalte du in welche felder schreibst....oder sprich mit uns via Discord, dann braucht man sowas nicht immer in github zu diskutieren

drexlma commented 1 year ago

Das Datenbank Feld specialsettings, dort habe ein einen speziellen Location eintrag

location /{ xxx}

d00p commented 1 year ago

liegt nicht am /{ sondern am regex der führende leerzeichen erwartet vor location, das hier sollte funktionieren:

diff --git a/lib/Froxlor/Cron/Http/Nginx.php b/lib/Froxlor/Cron/Http/Nginx.php
index c0cf4749..33d80e86 100644
--- a/lib/Froxlor/Cron/Http/Nginx.php
+++ b/lib/Froxlor/Cron/Http/Nginx.php
@@ -883,7 +883,7 @@ class Nginx extends HttpConfigBase
                // remove comments
                $vhost = implode("\n", preg_replace('/^(\s+)?#(.*)$/', '', explode("\n", $vhost)));
                // Break blocks into lines
-               $vhost = preg_replace("/^(\s+)location(.+)\{(.+)\}$/misU", "location $2 {\n $3 \n}", $vhost);
+               $vhost = preg_replace("/^(\s+)?location(.+)\{(.+)\}$/misU", "location $2 {\n $3 \n}", $vhost);
                // Break into array items
                $vhost = explode("\n", preg_replace('/[ \t]+/', ' ', trim(preg_replace('/\t+/', '', $vhost))));
                // Remove empty lines