From c9e577e22066402cc6f056f91b768fefd2ff9a20 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 26 Apr 2026 00:05:16 +0200 Subject: [PATCH] Update a new Nginx module to look and feel like Apache --- nginx/acl_security.pl | 7 +- nginx/config.info | 4 +- nginx/config.info.nl | 4 +- nginx/defaultacl | 1 + nginx/delete_servers.cgi | 61 +++++++++++ nginx/edit_fcgi.cgi | 2 +- nginx/edit_location.cgi | 2 +- nginx/edit_saccess.cgi | 2 +- nginx/edit_sdocs.cgi | 2 +- nginx/edit_server.cgi | 5 +- nginx/edit_sgzip.cgi | 2 +- nginx/edit_slogs.cgi | 2 +- nginx/edit_sproxy.cgi | 2 +- nginx/edit_srewrite.cgi | 2 +- nginx/edit_ssl.cgi | 2 +- nginx/edit_sssi.cgi | 2 +- nginx/help/label.ar.auto.html | 8 +- nginx/help/label.bg.auto.html | 9 +- nginx/help/label.ca.auto.html | 9 +- nginx/help/label.cs.auto.html | 8 +- nginx/help/label.da.auto.html | 8 +- nginx/help/label.de.auto.html | 9 +- nginx/help/label.el.auto.html | 9 +- nginx/help/label.es.auto.html | 9 +- nginx/help/label.eu.auto.html | 8 +- nginx/help/label.fa.auto.html | 8 +- nginx/help/label.fi.auto.html | 9 +- nginx/help/label.fr.auto.html | 9 +- nginx/help/label.hr.auto.html | 9 +- nginx/help/label.html | 4 +- nginx/help/label.hu.auto.html | 8 +- nginx/help/label.it.auto.html | 9 +- nginx/help/label.ja.auto.html | 7 +- nginx/help/label.ko.auto.html | 7 +- nginx/help/label.ms.auto.html | 8 +- nginx/help/label.nl.auto.html | 8 +- nginx/help/label.no.auto.html | 8 +- nginx/help/label.pl.auto.html | 8 +- nginx/help/label.pt.auto.html | 8 +- nginx/help/label.pt_BR.auto.html | 8 +- nginx/help/label.ru.auto.html | 9 +- nginx/help/label.sk.auto.html | 8 +- nginx/help/label.sv.auto.html | 8 +- nginx/help/label.tr.auto.html | 9 +- nginx/help/label.uk.auto.html | 8 +- nginx/help/label.zh.auto.html | 6 +- nginx/help/label.zh_TW.auto.html | 6 +- nginx/index.cgi | 176 +++++++++++++++++++++++-------- nginx/lang/ar.auto | 77 +++++++------- nginx/lang/bg.auto | 157 +++++++++++++-------------- nginx/lang/ca.auto | 121 ++++++++++----------- nginx/lang/cs.auto | 131 ++++++++++++----------- nginx/lang/da.auto | 147 +++++++++++++------------- nginx/lang/de.auto | 84 ++++++++------- nginx/lang/el.auto | 137 ++++++++++++------------ nginx/lang/en | 84 ++++++++------- nginx/lang/es.auto | 82 +++++++------- nginx/lang/eu.auto | 73 +++++++------ nginx/lang/fa.auto | 87 +++++++-------- nginx/lang/fi.auto | 77 +++++++------- nginx/lang/fr.auto | 84 ++++++++------- nginx/lang/hr.auto | 135 ++++++++++++------------ nginx/lang/hu.auto | 77 +++++++------- nginx/lang/it.auto | 165 +++++++++++++++-------------- nginx/lang/ja.auto | 84 ++++++++------- nginx/lang/ko.auto | 101 +++++++++--------- nginx/lang/ms.auto | 135 ++++++++++++------------ nginx/lang/nl | 79 ++++++++------ nginx/lang/nl.auto | 11 -- nginx/lang/no.auto | 149 +++++++++++++------------- nginx/lang/pl.auto | 165 +++++++++++++++-------------- nginx/lang/pt.auto | 163 ++++++++++++++-------------- nginx/lang/pt_BR.auto | 163 ++++++++++++++-------------- nginx/lang/ru.auto | 76 ++++++------- nginx/lang/sk.auto | 151 +++++++++++++------------- nginx/lang/sv.auto | 141 +++++++++++++------------ nginx/lang/tr.auto | 69 ++++++------ nginx/lang/uk.auto | 167 +++++++++++++++-------------- nginx/lang/zh.auto | 82 +++++++------- nginx/lang/zh_TW.auto | 82 +++++++------- nginx/nginx-lib.pl | 46 +++++++- nginx/restart.cgi | 5 +- nginx/save_fcgi.cgi | 2 +- nginx/save_saccess.cgi | 2 +- nginx/save_server.cgi | 13 ++- nginx/save_sgzip.cgi | 2 +- nginx/save_slogs.cgi | 2 +- nginx/save_sproxy.cgi | 2 +- nginx/save_srewrite.cgi | 2 +- nginx/save_ssl.cgi | 2 +- nginx/save_sssi.cgi | 2 +- nginx/start.cgi | 5 +- nginx/stop.cgi | 5 +- 93 files changed, 2314 insertions(+), 1839 deletions(-) create mode 100755 nginx/delete_servers.cgi delete mode 100644 nginx/lang/nl.auto diff --git a/nginx/acl_security.pl b/nginx/acl_security.pl index a3ae00b3a..242409cda 100755 --- a/nginx/acl_security.pl +++ b/nginx/acl_security.pl @@ -10,7 +10,7 @@ sub acl_security_form { my ($o) = @_; -# Allowed virtual hosts +# Allowed server blocks print &ui_table_row($text{'acl_vhosts'}, &ui_radio("vhosts_def", $o->{'vhosts'} ? 0 : 1, [ [ 1, $text{'acl_hosts1'} ], @@ -22,6 +22,10 @@ print &ui_table_row($text{'acl_vhosts'}, print &ui_table_row($text{'acl_edit'}, &ui_yesno_radio("edit", $o->{'edit'})); +# Can create server blocks? +print &ui_table_row($text{'acl_create'}, + &ui_yesno_radio("create", !defined($o->{'create'}) || $o->{'create'})); + # Can stop and start Nginx? print &ui_table_row($text{'acl_stop'}, &ui_yesno_radio("stop", $o->{'stop'})); @@ -52,6 +56,7 @@ my ($o) = @_; $o->{'vhosts'} = $in{'vhosts_def'} ? "" : join(" ", split(/\s+/, $in{'vhosts'})); $o->{'edit'} = $in{'edit'}; +$o->{'create'} = $in{'create'}; $o->{'root'} = $in{'root'}; $o->{'global'} = $in{'global'}; $o->{'logs'} = $in{'logs'}; diff --git a/nginx/config.info b/nginx/config.info index 7ff290a1f..fd090ea4c 100644 --- a/nginx/config.info +++ b/nginx/config.info @@ -1,6 +1,6 @@ nginx_config=Full path to Nginx config file,0 -add_to=File or directory for new virtual hosts,3,None (add to main config file) -add_link=Directory for links to new virtual host files,3,None +add_to=File or directory for new server blocks,3,Add to main config file +add_link=Directory for links to new server block files,3,None nginx_cmd=Full path to Nginx command,0 start_cmd=Command to start Nginx,0 stop_cmd=Command to stop Nginx,0 diff --git a/nginx/config.info.nl b/nginx/config.info.nl index 0d9663b5b..ffcf9a693 100644 --- a/nginx/config.info.nl +++ b/nginx/config.info.nl @@ -1,6 +1,6 @@ nginx_config=Volledig pad naar de Nginx config file,0 -add_to=File of directory voor de nieuwe virtuele host files,3,Geen (toevoegen aan de hoofd config file) -add_link=Directory voor de links naar de nieuwe virtuele host files,3,Geen +add_to=File or directory for new server block files,3,Add to main config file +add_link=Directory for links to new server block files,3,Geen nginx_cmd=Volledig pad naar de Nginx opdracht,0 start_cmd=Opdracht om Nginx te starten,0 stop_cmd=Opdracht om Nginx te stoppen,0 diff --git a/nginx/defaultacl b/nginx/defaultacl index 26cbb04be..76fc1da86 100644 --- a/nginx/defaultacl +++ b/nginx/defaultacl @@ -3,5 +3,6 @@ root=/ global=1 user=root edit=1 +create=1 stop=1 logs=1 diff --git a/nginx/delete_servers.cgi b/nginx/delete_servers.cgi new file mode 100755 index 000000000..fed1a6ef7 --- /dev/null +++ b/nginx/delete_servers.cgi @@ -0,0 +1,61 @@ +#!/usr/local/bin/perl +# Delete selected server blocks + +use strict; +use warnings; +require './nginx-lib.pl'; +our (%text, %in, %config, %access); +&ReadParse(); +&error_setup($text{'delete_err'}); +$access{'edit'} || &error($text{'server_ecannotedit'}); + +my @ids = split(/\0/, $in{'d'} || ""); +@ids || &error($text{'delete_enone'}); + +# Validate the selected server blocks before locking config files. +foreach my $id (@ids) { + my $server = &find_server($id); + $server || &error($text{'server_egone'}); + &can_edit_server($server) || &error($text{'server_ecannot'}); + &is_default_server_block($server) && &error($text{'delete_edefault'}); + } + +&lock_all_config_files(); +my $conf = &get_config(); +my $http = &find("http", $conf); +if (!$http) { + &unlock_all_config_files(); + &error(&text('index_ehttp', "$config{'nginx_config'}")); + } +my @servers; +foreach my $id (@ids) { + my $server = &find_server($id); + if (!$server) { + &unlock_all_config_files(); + &error($text{'server_egone'}); + } + if (!&can_edit_server($server)) { + &unlock_all_config_files(); + &error($text{'server_ecannot'}); + } + if (&is_default_server_block($server)) { + &unlock_all_config_files(); + &error($text{'delete_edefault'}); + } + push(@servers, $server); + } +foreach my $server (@servers) { + &save_directive($http, [ $server ], [ ]); + } +&flush_config_file_lines(); +&unlock_all_config_files(); +foreach my $server (@servers) { + &delete_server_link($server); + } +my %done_file; +foreach my $server (@servers) { + next if ($done_file{$server->{'file'}}++); + &delete_server_file_if_empty($server); + } +&webmin_log("delete", "servers", scalar(@servers)); +&redirect(""); diff --git a/nginx/edit_fcgi.cgi b/nginx/edit_fcgi.cgi index 5412a1a30..7ae0c684e 100755 --- a/nginx/edit_fcgi.cgi +++ b/nginx/edit_fcgi.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host FCGI options +# Show server block FCGI options use strict; use warnings; diff --git a/nginx/edit_location.cgi b/nginx/edit_location.cgi index af52dd43c..29f7d100f 100644 --- a/nginx/edit_location.cgi +++ b/nginx/edit_location.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show the config for one location inside a virtual host +# Show the config for one location inside a server block use strict; use warnings; diff --git a/nginx/edit_saccess.cgi b/nginx/edit_saccess.cgi index 7f559e44b..17bba98e1 100755 --- a/nginx/edit_saccess.cgi +++ b/nginx/edit_saccess.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host access control options +# Show server block access control options use strict; use warnings; diff --git a/nginx/edit_sdocs.cgi b/nginx/edit_sdocs.cgi index 014f44d7f..d2be057bc 100755 --- a/nginx/edit_sdocs.cgi +++ b/nginx/edit_sdocs.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show document related options for a virtual host +# Show document related options for a server block use strict; use warnings; diff --git a/nginx/edit_server.cgi b/nginx/edit_server.cgi index f891b6cca..8df1bb388 100644 --- a/nginx/edit_server.cgi +++ b/nginx/edit_server.cgi @@ -8,8 +8,9 @@ our (%text, %in, %access); &ReadParse(); my $server; +my $can_create = !defined($access{'create'}) || $access{'create'}; if ($in{'new'}) { - $access{'vhosts'} && &error($text{'server_ecannotcreate'}); + $can_create || &error($text{'server_ecannotcreate'}); &ui_print_header(undef, $text{'server_create'}, ""); $server = { 'name' => 'server', 'members' => [ ] }; @@ -74,7 +75,7 @@ if ($in{'id'}) { print &ui_links_row(\@links); } -if ($access{'edit'}) { +if ($access{'edit'} || ($in{'new'} && $can_create)) { # Show form to edit name, IPs and root if (!$in{'new'}) { print &ui_hr(); diff --git a/nginx/edit_sgzip.cgi b/nginx/edit_sgzip.cgi index f25471b2b..a00bdb48e 100755 --- a/nginx/edit_sgzip.cgi +++ b/nginx/edit_sgzip.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host gzip options +# Show server block gzip options use strict; use warnings; diff --git a/nginx/edit_slogs.cgi b/nginx/edit_slogs.cgi index ac95d029e..fa1293c67 100755 --- a/nginx/edit_slogs.cgi +++ b/nginx/edit_slogs.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host logging options +# Show server block logging options use strict; use warnings; diff --git a/nginx/edit_sproxy.cgi b/nginx/edit_sproxy.cgi index a08fef3ac..6fa82a3fd 100755 --- a/nginx/edit_sproxy.cgi +++ b/nginx/edit_sproxy.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host proxy options +# Show server block proxy options use strict; use warnings; diff --git a/nginx/edit_srewrite.cgi b/nginx/edit_srewrite.cgi index 379ec0375..828469d02 100755 --- a/nginx/edit_srewrite.cgi +++ b/nginx/edit_srewrite.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host URL re-write options +# Show server block URL re-write options use strict; use warnings; diff --git a/nginx/edit_ssl.cgi b/nginx/edit_ssl.cgi index 0e6bf3c4c..876f8ddaf 100755 --- a/nginx/edit_ssl.cgi +++ b/nginx/edit_ssl.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host SSL options +# Show server block SSL options use strict; use warnings; diff --git a/nginx/edit_sssi.cgi b/nginx/edit_sssi.cgi index 4be1bc561..089e0e731 100755 --- a/nginx/edit_sssi.cgi +++ b/nginx/edit_sssi.cgi @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -# Show virtual host server-side include options +# Show server block server-side include options use strict; use warnings; diff --git a/nginx/help/label.ar.auto.html b/nginx/help/label.ar.auto.html index bfc590b13..e508bf807 100644 --- a/nginx/help/label.ar.auto.html +++ b/nginx/help/label.ar.auto.html @@ -1 +1,7 @@ -
هل تم تمكين موقع Nginx الإلكتروني؟
إذا تم تحديده ، فسيكون لهذا الخادم الافتراضي موقع ويب مزود بواسطة خادم الويب Nginx.