-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63065d7
commit 39a2d60
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ phpunit.xml | |
wsl-init.log | ||
.backup/* | ||
.DS_Store | ||
/ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env bash | ||
|
||
declare -A params=$6 # Create an associative array | ||
declare -A headers=${9} # Create an associative array | ||
paramsTXT="" | ||
if [ -n "$6" ]; then | ||
for element in "${!params[@]}" | ||
do | ||
paramsTXT="${paramsTXT} | ||
SetEnv ${element} \"${params[$element]}\"" | ||
done | ||
fi | ||
headersTXT="" | ||
if [ -n "${9}" ]; then | ||
for element in "${!headers[@]}" | ||
do | ||
headersTXT="${headersTXT} | ||
Header always set ${element} \"${headers[$element]}\"" | ||
done | ||
fi | ||
|
||
if [ -n "$2" ] | ||
then | ||
if ! [[ "$2" =~ ^[0-9]+$ ]] | ||
then | ||
proxyPass=" | ||
ProxyPass / ${2}/ | ||
ProxyPassReverse / ${2}/ | ||
" | ||
else proxyPass=" | ||
ProxyPass / http://127.0.0.1:$2/ | ||
ProxyPassReverse / http://127.0.0.1:$2/ | ||
" | ||
fi | ||
else proxyPass=" | ||
ProxyPass / http://127.0.0.1/ | ||
ProxyPassReverse / http://127.0.0.1/ | ||
" | ||
fi | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
sudo service nginx stop | ||
sudo systemctl disable nginx | ||
sudo systemctl enable apache2 | ||
|
||
sudo a2enmod proxy | ||
sudo a2enmod proxy_http | ||
sudo a2enmod proxy_ajp | ||
sudo a2enmod rewrite | ||
sudo a2enmod deflate | ||
sudo a2enmod headers | ||
sudo a2enmod proxy_balancer | ||
sudo a2enmod proxy_connect | ||
sudo a2enmod proxy_html | ||
|
||
block="<VirtualHost *:$3> | ||
ServerAdmin webmaster@localhost | ||
ServerName $1 | ||
ServerAlias www.$1 | ||
$paramsTXT | ||
$headersTXT | ||
$proxyPass | ||
</VirtualHost> | ||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet | ||
" | ||
|
||
echo "$block" > "/etc/apache2/sites-available/$1.conf" | ||
ln -fs "/etc/apache2/sites-available/$1.conf" "/etc/apache2/sites-enabled/$1.conf" | ||
|
||
blockssl="<IfModule mod_ssl.c> | ||
<VirtualHost *:$4> | ||
ServerAdmin webmaster@localhost | ||
ServerName $1 | ||
ServerAlias www.$1 | ||
$paramsTXT | ||
SSLEngine on | ||
SSLCertificateFile /etc/ssl/certs/$1.crt | ||
SSLCertificateKeyFile /etc/ssl/certs/$1.key | ||
$proxyPass | ||
</VirtualHost> | ||
</IfModule> | ||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet | ||
" | ||
|
||
echo "$blockssl" > "/etc/apache2/sites-available/$1-ssl.conf" | ||
ln -fs "/etc/apache2/sites-available/$1-ssl.conf" "/etc/apache2/sites-enabled/$1-ssl.conf" | ||
|
||
ps auxw | grep apache2 | grep -v grep > /dev/null | ||
|
||
service apache2 restart | ||
|
||
if [ $? == 0 ] | ||
then | ||
service apache2 reload | ||
fi |