From 2f5aa5254cdda9c4095d3b39b783d96a4ac2af6b Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 13 Feb 2019 21:15:27 +0100 Subject: [PATCH] new: dev: [apache] allow empty domain to make default site entry. --- apache/lib/common | 34 ++++++++++++++---- apache/test/vhost | 62 +++++++++++++++++++++++++++++++++ apache/test/vhost_cert_provider | 1 + 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/apache/lib/common b/apache/lib/common index e9f3952..850f1cb 100644 --- a/apache/lib/common +++ b/apache/lib/common @@ -543,6 +543,14 @@ EOF __vhost_head_statement() { local cfg="$1" protocol="$2" domain="$3" server_aliases admin_mail prefix admin_mail=$(e "$1" | cfg-get-value "admin-mail" 2>/dev/null) || true + if [ -z "$admin_mail" ]; then + if [ -z "$domain" ]; then + admin_mail=webmaster@localhost + else + admin_mail=${admin_mail:-contact@$domain} + fi + fi + server_aliases=$(e "$cfg" | cfg-get-value server-aliases 2>/dev/null) || true [ "$server_aliases" == None ] && server_aliases="" if [ "$server_aliases" ]; then @@ -561,18 +569,25 @@ __vhost_head_statement() { prefix= fi + if [ "$domain" ]; then + log_prefix="${prefix}${domain}_" + else + log_prefix="" + fi + cat < -$(echo "$head_statement" | prefix " ") -$(echo "$custom_rules" | prefix " ") -$(echo "$content_statement" | prefix " ") +$( +{ + echo "$head_statement" + [ "$custom_rules" ] && echo "$custom_rules" + echo "$content_statement" +} | prefix " ") ## Forbid any cache, this is only usefull on dev server. #Header set Cache-Control "no-cache" @@ -744,6 +762,8 @@ __vhost_publish_dir_statement() { local_path="/var/www/${dest}" cat < ErrorLog /var/log/apache2/www.example.com_error.log ErrorLog syslog:local2 + ## ## Publish directory /var/www/www.example.com ## @@ -337,3 +338,64 @@ is out ' ' RTRIM + + + + +## +## single def no domain +## + +try " +apache_vhost_statement publish_dir ,http, ' +apache-custom-rules: | + RewriteEngine On + RewriteCond %{QUERY_STRING} !skin=formanoo + RewriteRule ^(/web/webclient/home.*)$ $1?skin=formanoo [L,QSA,R=302] +target: popo:3333 +' "" +" "http without domain" +noerror +is out ' + + ServerAdmin webmaster@localhost + + ServerSignature Off + CustomLog /var/log/apache2/access.log combined + ErrorLog /var/log/apache2/error.log + ErrorLog syslog:local2 + + + ## + ## Custom rules + ## + + RewriteEngine On + RewriteCond %{QUERY_STRING} !skin=formanoo + RewriteRule ^(/web/webclient/home.*)$ ?skin=formanoo [L,QSA,R=302] + + + ## + ## Publish directory /var/www/html + ## + + DocumentRoot /var/www/html + + + Options FollowSymLinks + AllowOverride None + + + + Options Indexes FollowSymLinks MultiViews + AllowOverride all + Allow from all + + + ## Forbid any cache, this is only usefull on dev server. + #Header set Cache-Control "no-cache" + #Header set Access-Control-Allow-Origin "*" + #Header set Access-Control-Allow-Methods "POST, GET, OPTIONS" + #Header set Access-Control-Allow-Headers "origin, content-type, accept" + +' RTRIM diff --git a/apache/test/vhost_cert_provider b/apache/test/vhost_cert_provider index fe7125c..b7f8395 100644 --- a/apache/test/vhost_cert_provider +++ b/apache/test/vhost_cert_provider @@ -323,6 +323,7 @@ is out part 'file_put $SERVICE_CONFIGSTORE/etc/apache2/sites-enabled/www.example | ServerName www.example.com | ServerAlias example.fr | ServerAlias example.de + | | ServerSignature Off' RTRIM is out part ' | ## Auto-redirection from http to https