Compare commits
3 Commits
cbc48620de
...
0e0531154e
Author | SHA1 | Date | |
---|---|---|---|
|
0e0531154e | ||
|
17fa4f70fb | ||
|
181aaf401e |
108
BashScripts/install-apache/apache-add-proxy.sh
Normal file
108
BashScripts/install-apache/apache-add-proxy.sh
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Make sure script is ran as root
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
exec sudo /bin/bash "$0" "$@"
|
||||||
|
fi
|
||||||
|
if [[ $1 = "" ]]; then
|
||||||
|
echo "Usage: apache-add-proxy.sh [domain.com] [http://192.168.0.108:3000/]"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
domain=$(perl -e "(\$d)=\"$1\"=~/(\\w+\\.\\w+)\$/;print \$d")
|
||||||
|
host=$(perl -e "(\$d)=\"$1\"=~/(\\w+)\\.\\w+\\.\\w+\$/;print \$d")
|
||||||
|
red='\033[0;31m'
|
||||||
|
green='\033[0;32m'
|
||||||
|
nocolor='\033[0m'
|
||||||
|
if [[ -f "/etc/apache2/sites-enabled/$1.conf" ]]; then
|
||||||
|
echo "Config file $1.conf does already exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -d "/var/www/$1" ]]; then
|
||||||
|
mkdir "/var/www/$1"
|
||||||
|
fi
|
||||||
|
if [[ ! -d "/var/www/$1/logs" ]]; then
|
||||||
|
mkdir "/var/www/$1/logs"
|
||||||
|
fi
|
||||||
|
chmod -R 777 "/var/www/$1"
|
||||||
|
|
||||||
|
echo "Searching for SSL certificate for $domain ..."
|
||||||
|
declare -a CertDirectories=("/var/www/$domain/certs" "/var/www/SSL-Certificates")
|
||||||
|
unset CertDirectory
|
||||||
|
for TestDirectory in "${CertDirectories[@]}"
|
||||||
|
do
|
||||||
|
if [[ -f "$TestDirectory/$domain-crt.pem" ]] && [[ -f "$TestDirectory/$domain-key.pem" ]] && [[ -f "$TestDirectory/$domain-chain.pem" ]]; then
|
||||||
|
echo "SSL certificate found!"
|
||||||
|
CertDirectory=$TestDirectory;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $host = "" ]]; then
|
||||||
|
serveralias="ServerAlias www.$1"
|
||||||
|
else
|
||||||
|
serveralias=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Adding site
|
||||||
|
cat <<EOT1 >> "/etc/apache2/sites-enabled/$1.conf"
|
||||||
|
<VirtualHost *:80>
|
||||||
|
|
||||||
|
ServerName $1
|
||||||
|
$serveralias
|
||||||
|
ServerAdmin webmaster@$1
|
||||||
|
|
||||||
|
HostnameLookups Off
|
||||||
|
ErrorLog /var/www/$1/logs/error.log
|
||||||
|
CustomLog /var/www/$1/logs/access.log combined
|
||||||
|
|
||||||
|
<IfModule proxy_module>
|
||||||
|
<IfModule proxy_http_module>
|
||||||
|
ProxyPreserveHost On
|
||||||
|
ProxyPass "/" $2
|
||||||
|
ProxyPassReverse "/" $2
|
||||||
|
</IfModule>
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
</VirtualHost>
|
||||||
|
EOT1
|
||||||
|
|
||||||
|
if [[ ! $CertDirectory = "" ]]; then
|
||||||
|
echo Adding SSL settings
|
||||||
|
cat <<EOT2 >> "/etc/apache2/sites-enabled/$1.conf"
|
||||||
|
<IfModule ssl_module>
|
||||||
|
<VirtualHost *:443>
|
||||||
|
|
||||||
|
ServerName $1
|
||||||
|
$serveralias
|
||||||
|
ServerAdmin webmaster@$1
|
||||||
|
|
||||||
|
HostnameLookups Off
|
||||||
|
LogFormat "%h %l %u %{%Y-%m-%d %H:%M:%S}t \"%r\" %>s %b" mylogformat
|
||||||
|
ErrorLog /var/www/$1/logs/error-ssl.log
|
||||||
|
CustomLog /var/www/$1/logs/access-ssl.log mylogformat
|
||||||
|
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile "$CertDirectory/$domain-crt.pem"
|
||||||
|
SSLCertificateKeyFile "$CertDirectory/$domain-key.pem"
|
||||||
|
SSLCertificateChainFile "$CertDirectory/$domain-chain.pem"
|
||||||
|
BrowserMatch "MSIE [2-5]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
|
||||||
|
|
||||||
|
<IfModule proxy_module>
|
||||||
|
<IfModule proxy_http_module>
|
||||||
|
ProxyPreserveHost On
|
||||||
|
ProxyPass "/" $2
|
||||||
|
ProxyPassReverse "/" $2
|
||||||
|
</IfModule>
|
||||||
|
</IfModule>
|
||||||
|
</VirtualHost>
|
||||||
|
</IfModule>
|
||||||
|
EOT2
|
||||||
|
fi
|
||||||
|
|
||||||
|
apacheresult=$(apachectl configtest 2>&1)
|
||||||
|
if [[ ! $apacheresult =~ "Syntax OK" ]]; then
|
||||||
|
rm "/etc/apache2/sites-enabled/$1.conf"
|
||||||
|
echo "Errors detected:"
|
||||||
|
echo "$apacheresult"
|
||||||
|
else
|
||||||
|
echo "Site added!"
|
||||||
|
systemctl restart apache2
|
||||||
|
fi
|
@ -4,7 +4,7 @@ if [[ $EUID -ne 0 ]]; then
|
|||||||
exec sudo /bin/bash "$0" "$@"
|
exec sudo /bin/bash "$0" "$@"
|
||||||
fi
|
fi
|
||||||
if [[ $1 = "" ]]; then
|
if [[ $1 = "" ]]; then
|
||||||
echo "Usage: add-site.sh [domain.com]"
|
echo "Usage: apache-add-site.sh [domain.com]"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
domain=$(perl -e "(\$d)=\"$1\"=~/(\\w+\\.\\w+)\$/;print \$d")
|
domain=$(perl -e "(\$d)=\"$1\"=~/(\\w+\\.\\w+)\$/;print \$d")
|
||||||
@ -12,19 +12,17 @@ host=$(perl -e "(\$d)=\"$1\"=~/(\\w+)\\.\\w+\\.\\w+\$/;print \$d")
|
|||||||
red='\033[0;31m'
|
red='\033[0;31m'
|
||||||
green='\033[0;32m'
|
green='\033[0;32m'
|
||||||
nocolor='\033[0m'
|
nocolor='\033[0m'
|
||||||
|
if [[ -f "/etc/apache2/sites-enabled/$1.conf" ]]; then
|
||||||
|
echo "Config file $1.conf does already exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if [[ ! -d "/var/www/$1/www" ]]; then
|
if [[ ! -d "/var/www/$1/www" ]]; then
|
||||||
# echo "Directory '/var/www/$1/www' does not exist"
|
|
||||||
# exit 1
|
|
||||||
mkdir "/var/www/$1"
|
mkdir "/var/www/$1"
|
||||||
mkdir "/var/www/$1/www"
|
mkdir "/var/www/$1/www"
|
||||||
fi
|
fi
|
||||||
if [[ ! -d "/var/www/$1/logs" ]]; then
|
if [[ ! -d "/var/www/$1/logs" ]]; then
|
||||||
mkdir "/var/www/$1/logs"
|
mkdir "/var/www/$1/logs"
|
||||||
fi
|
fi
|
||||||
if [[ -f "/etc/apache2/sites-enabled/$1.conf" ]]; then
|
|
||||||
echo "Config file $1.conf does already exist"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
chmod -R 777 "/var/www/$1"
|
chmod -R 777 "/var/www/$1"
|
||||||
|
|
||||||
echo "Searching for SSL certificate for $domain ..."
|
echo "Searching for SSL certificate for $domain ..."
|
||||||
|
@ -65,16 +65,28 @@ Eller för en hel katalog (rekursivt)
|
|||||||
|
|
||||||
## Autentisering
|
## Autentisering
|
||||||
|
|
||||||
#### Skapa ny privat SSH nyckel
|
### Linux
|
||||||
|
|
||||||
|
* Skapa ny SSH nyckel
|
||||||
|
|
||||||
<code>ssh-keygen -t rsa -b 4096</code>
|
<code>ssh-keygen -t rsa -b 4096</code>
|
||||||
|
|
||||||
Alternativt lägg till <code>-C "<user@domain.com>"</code>
|
Alternativt lägg till <code>-C "<user@domain.com>"</code>
|
||||||
|
|
||||||
|
* Lägg till id_rsa.pub som SSH-nyckel för repot
|
||||||
|
|
||||||
|
* Sätt remote repo till git@... istället för https:// ...
|
||||||
|
|
||||||
|
* Gör en pull för att verifiera att allt fungerar
|
||||||
|
|
||||||
#### Aktivera credential store
|
#### Aktivera credential store
|
||||||
|
|
||||||
|
Alternativt aktivera credential.helper store. Observera att detta sparar inloggningsinformation i klartext i ~/.git-credentials
|
||||||
|
|
||||||
<pre><code>git config --global credential.helper store</code></pre>
|
<pre><code>git config --global credential.helper store</code></pre>
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
#### Aktivera Windows Credentials manager
|
#### Aktivera Windows Credentials manager
|
||||||
|
|
||||||
<pre><code>git config --global credential.helper manager
|
<pre><code>git config --global credential.helper manager
|
||||||
@ -82,4 +94,4 @@ git config --list</code></pre>
|
|||||||
|
|
||||||
#### Kontrollera användarinformation lagrad i Windows Credentials manager
|
#### Kontrollera användarinformation lagrad i Windows Credentials manager
|
||||||
|
|
||||||
<code>rundll32.exe keymgr.dll,KRShowKeyMgr</code>
|
<code>rundll32.exe keymgr.dll,KRShowKeyMgr</code>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user