REL-0.9 Better mass virtual hosting wildcards

This commit is contained in:
cytopia 2017-05-06 15:50:48 +02:00
parent bb0abf4794
commit 54e00598cd
No known key found for this signature in database
GPG Key ID: 6D56EDB8695128A2
10 changed files with 29 additions and 90 deletions

View File

@ -1,30 +0,0 @@
#!/usr/bin/env php
<?php
// TODO: logpath could also be passed via CMD argument
// so this script could be more general
$path = '/var/log/apache-2.2';
$fh_timeout = 30; // 30 sek.
$fd = fopen('php://stdin', 'r');
while (!feof($fd)) {
$row = fgets($fd);
list($vhost, $h, $l, $u, $t, $r, $s, $b, $referrer, $ua) = explode(';', $row, 10);
if (!isset(${$vhost})) {
${$vhost} = fopen($path . '/' . $vhost . '_access.log', 'a+');
}
$lastwrite[$vhost] = time();
fputs(${$vhost}, "$h $l $u $t $r $s $b $referrer $ua");
foreach ($lastwrite as $vhost => $time) {
if ((time() - ($time + 30)) >= 0) {
fclose(${$vhost});
unset(${$vhost});
unset($lastwrite[$vhost]);
}
}
}

View File

@ -1,30 +0,0 @@
#!/usr/bin/env php
<?php
// TODO: logpath could also be passed via CMD argument
// so this script could be more general
$path = '/var/log/apache-2.4';
$fh_timeout = 30; // 30 sek.
$fd = fopen('php://stdin', 'r');
while (!feof($fd)) {
$row = fgets($fd);
list($vhost, $h, $l, $u, $t, $r, $s, $b, $referrer, $ua) = explode(';', $row, 10);
if (!isset(${$vhost})) {
${$vhost} = fopen($path . '/' . $vhost . '_access.log', 'a+');
}
$lastwrite[$vhost] = time();
fputs(${$vhost}, "$h $l $u $t $r $s $b $referrer $ua");
foreach ($lastwrite as $vhost => $time) {
if ((time() - ($time + 30)) >= 0) {
fclose(${$vhost});
unset(${$vhost});
unset($lastwrite[$vhost]);
}
}
}

View File

@ -5,6 +5,10 @@ NameVirtualHost *:80
<VirtualHost _default_:80>
ServerName localhost
ServerAlias 127.0.0.1
ServerAlias 172.16.238.*
ServerAlias httpd
ServerAdmin root@localhost
ErrorLog /var/log/apache-2.2/localhost-error.log
@ -26,6 +30,3 @@ NameVirtualHost *:80
Allow from all
</Directory>
</VirtualHost>

View File

@ -8,15 +8,12 @@
UseCanonicalName Off
ServerName localhost
ServerAlias *.loc
ServerAlias *.*
ServerAdmin root@localhost
# splitlogs.php is a custom script, which will filter the domain
# and create separate logfiles per domain.
LogFormat "%V;%h;%l;%u;%t;\"%r\";%>s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon
CustomLog "|/opt/bin/splitlogs.php" vcommon
ErrorLog /var/log/apache-2.2/other-error.log
CustomLog "/var/log/apache-2.2/projects-access.log" vcommon
ErrorLog /var/log/apache-2.2/projects-error.log
DirectoryIndex index.php index.html
@ -38,6 +35,3 @@
Allow from all
</Directory>
</VirtualHost>

View File

@ -5,6 +5,10 @@
<VirtualHost _default_:80>
ServerName localhost
ServerAlias 127.0.0.1
ServerAlias 172.16.238.*
ServerAlias httpd
ServerAdmin root@localhost
ErrorLog /var/log/apache-2.4/localhost-error.log
@ -27,6 +31,3 @@
Require all granted
</Directory>
</VirtualHost>

View File

@ -8,15 +8,12 @@
UseCanonicalName Off
ServerName localhost
ServerAlias *.loc
ServerAlias *.*
ServerAdmin root@localhost
# splitlogs.php is a custom script, which will filter the domain
# and create separate logfiles per domain.
LogFormat "%V;%h;%l;%u;%t;\"%r\";%>s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon
CustomLog "|/opt/bin/splitlogs.php" vcommon
ErrorLog /var/log/apache-2.4/other-error.log
CustomLog "/var/log/apache-2.4/projects-access.log" vcommon
ErrorLog /var/log/apache-2.4/projects-error.log
DirectoryIndex index.php index.html
@ -39,6 +36,3 @@
Require all granted
</Directory>
</VirtualHost>

View File

@ -5,6 +5,11 @@
server {
listen 80 default_server;
server_name _;
server_name localhost;
server_name 127\.0\.0\.1;
server_name httpd;
server_name 172\.16\.238\..*;
# Root directive
root /var/www/default/htdocs;

View File

@ -4,14 +4,14 @@
server {
listen 80;
server_name ~^(?<domain>.+)\.loc$;
server_name ~^(?<domain>.+)\.[a-zA-Z]+$;
# Root directive
root /shared/httpd/$domain/htdocs/;
index index.php;
access_log /var/log/nginx-mainline/$domain-access.log main;
error_log /var/log/nginx-mainline/other-error.log warn;
access_log /var/log/nginx-mainline/projects-access.log main;
error_log /var/log/nginx-mainline/projects-error.log warn;
# Front-controller pattern as recommended by the nginx docs

View File

@ -5,6 +5,10 @@
server {
listen 80 default_server;
server_name _;
server_name localhost;
server_name 127\.0\.0\.1;
server_name httpd;
server_name 172\.16\.238\..*;
# Root directive
root /var/www/default/htdocs;

View File

@ -4,14 +4,14 @@
server {
listen 80;
server_name ~^(?<domain>.+)\.loc$;
server_name ~^(?<domain>.+)\.[a-zA-Z]+$;
# Root directive
root /shared/httpd/$domain/htdocs/;
index index.php;
access_log /var/log/nginx-stable/$domain-access.log main;
error_log /var/log/nginx-stable/other-error.log warn;
access_log /var/log/nginx-stable/projects-access.log main;
error_log /var/log/nginx-stable/projects-error.log warn;
# Front-controller pattern as recommended by the nginx docs