bundle IPv4 and IPv6 in vhost configuration block.

This commit is contained in:
Christoph 2018-01-11 16:50:54 +01:00
parent d5dde995d1
commit 3f96a75f55

View File

@ -1335,10 +1335,8 @@ else
## - Get IPv6 Address
## -
if echo $line | grep -e "\s*<VirtualHost" \
| grep 80 \
| grep -e "[0-9a-f]\+:[0-9a-f]\+:[0-9a-f]\+:[0-9a-f]\+" > /dev/null 2>&1 ; then
_ipv6=`echo $line | awk '{print$2}' | cut -d ']' -f 1 | cut -d '[' -f 2 `
if echo $line | grep -E "\s*<VirtualHost" | grep -E "\[.+\]" > /dev/null 2>&1 ; then
_ipv6="$(echo $line | grep -E "\s*<VirtualHost" | grep -o -E "\[.+\]" | cut -d ']' -f 1 | cut -d '[' -f 2)"
continue
fi
@ -2733,14 +2731,22 @@ fi
for _alias in "${_server_aliases_arr[@]}" ; do
cat <<EOF >> ${_new_vhost_config_file}
# --- $_alias
EOF
if [ "$?" != "0" ]; then
_failed=true
fi
done
cat <<EOF >> ${_new_vhost_config_file}
if [ "$_ipv6" != "disabled" ]; then
cat <<EOF >> ${_new_vhost_config_file}
<VirtualHost $_ipv4:80 [$_ipv6]:80>
EOF
else
cat <<EOF >> ${_new_vhost_config_file}
<VirtualHost $_ipv4:80>
EOF
fi
cat <<EOF >> ${_new_vhost_config_file}
ServerAdmin $server_admin
@ -2836,10 +2842,19 @@ if [ "$?" != "0" ]; then
fi
if $_https ; then
if [ "$_ipv6" != "disabled" ]; then
cat <<EOF >> ${_new_vhost_config_file}
<VirtualHost $_ipv4:443 [$_ipv6]:443>
EOF
else
cat <<EOF >> ${_new_vhost_config_file}
<VirtualHost $_ipv4:443>
EOF
fi
cat <<EOF >> ${_new_vhost_config_file}
ServerAdmin $server_admin
@ -2942,219 +2957,6 @@ EOF
fi
if [ "$_ipv6" != "disabled" ]; then
cat <<EOF >> ${_new_vhost_config_file}
# ---
# --- IPv6
# ---
<VirtualHost [$_ipv6]:80>
ServerAdmin $server_admin
ServerName $_server_name
EOF
if [ "$?" != "0" ]; then
_failed=true
fi
for _alias in "${_server_aliases_arr[@]}" ; do
cat <<EOF >> ${_new_vhost_config_file}
ServerAlias $_alias
EOF
if [ "$?" != "0" ]; then
_failed=true
fi
done
if $_suEXEC ; then
cat <<EOF >> ${_new_vhost_config_file}
SuexecUserGroup $suEXEC_user $suEXEC_group
EOF
fi
if $_https_only ; then
cat <<EOF >> ${_new_vhost_config_file}
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
EOF
elif [ "$_type" = "FCGID" ]; then
cat <<EOF >> ${_new_vhost_config_file}
DocumentRoot $_doc_root
<Directory "${_doc_root}">
Require all granted
AllowOverride All
FCGIWrapper $FCGI_Wrapper
<FilesMatch \.php\$>
SetHandler fcgid-script
</FilesMatch>
Options +ExecCGI
</Directory>
EOF
elif [ "$_type" = "PHP-FPM" ]; then
cat <<EOF >> ${_new_vhost_config_file}
#ProxyErrorOverride On
<FilesMatch \\.php\$>
SetHandler $_set_handler_fpm
</FilesMatch>
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
DocumentRoot $_doc_root
<Directory "${_doc_root}">
Require all granted
AllowOverride All
</Directory>
EOF
else
cat <<EOF >> ${_new_vhost_config_file}
DocumentRoot $_doc_root
<Directory "${_doc_root}">
AllowOverride All
Require all granted
</Directory>
EOF
fi # if $_https_only ; then
if [ -n "$_custom_ipv6_log" ]; then
cat <<EOF >> ${_new_vhost_config_file}
CustomLog $_custom_ipv6_log base_requests
EOF
fi
cat <<EOF >> ${_new_vhost_config_file}
CustomLog $_combined_custom_log combined
ErrorLog $_error_log
</VirtualHost>
EOF
if [ "$?" != "0" ]; then
_failed=true
fi
if $_https ; then
cat <<EOF >> ${_new_vhost_config_file}
<VirtualHost [$_ipv6]:443>
ServerAdmin $server_admin
ServerName $_server_name
EOF
if [ "$?" != "0" ]; then
_failed=true
fi
for _alias in "${_server_aliases_arr[@]}" ; do
cat <<EOF >> $_new_vhost_config_file
ServerAlias $_alias
EOF
if [ "$?" != "0" ]; then
_failed=true
fi
done
if $_suEXEC ; then
cat <<EOF >> ${_new_vhost_config_file}
SuexecUserGroup $suEXEC_user $suEXEC_group
EOF
fi
if [ "$_type" = "FCGID" ]; then
cat <<EOF >> ${_new_vhost_config_file}
DocumentRoot $_doc_root
<Directory "${_doc_root}">
Require all granted
AllowOverride All
FCGIWrapper $FCGI_Wrapper
<FilesMatch \.php\$>
SetHandler fcgid-script
</FilesMatch>
Options +ExecCGI
</Directory>
EOF
elif [ "$_type" = "PHP-FPM" ]; then
cat <<EOF >> ${_new_vhost_config_file}
#ProxyErrorOverride On
<FilesMatch \\.php\$>
SetHandler $_set_handler_fpm
</FilesMatch>
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
DocumentRoot $_doc_root
<Directory "${_doc_root}">
Require all granted
AllowOverride All
</Directory>
EOF
else
cat <<EOF >> ${_new_vhost_config_file}
DocumentRoot $_doc_root
<Directory "${_doc_root}">
AllowOverride All
Require all granted
</Directory>
EOF
fi # if [ "$_type" = "FCGID" ]
cat <<EOF >> ${_new_vhost_config_file}
SSLEngine on
SSLCertificateFile $_ssl_cert_file
SSLCertificateKeyFile $_ssl_key_file
EOF
if [ -n "$_ssl_chain_file" ]; then
cat <<EOF >> ${_new_vhost_config_file}
SSLCertificateChainFile $_ssl_chain_file
EOF
fi
if [ -n "$_custom_ipv6_log" ]; then
cat <<EOF >> ${_new_vhost_config_file}
CustomLog $_custom_ipv6_log base_requests
EOF
fi
cat <<EOF >> ${_new_vhost_config_file}
CustomLog $_combined_custom_log combined
ErrorLog $_error_log
</VirtualHost>
EOF
if [ "$?" != "0" ]; then
_failed=true
fi
fi # if $_https ; then
fi # if [ "$_ipv6" != "disabled" ]; then
if ! $_failed ; then
echo_ok
else