From 21ae741d11b591a37c43a32e81c8fdc366998a78 Mon Sep 17 00:00:00 2001 From: rohhie Date: Tue, 9 May 2023 08:11:54 +0900 Subject: [PATCH] Add test environment to apache --- 01-setup.sh | 3 ++- 10-hosts.sh | 2 +- 91-teardown.sh | 1 + apache/test.conf | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 apache/test.conf diff --git a/01-setup.sh b/01-setup.sh index 9f803bd..04d3e7a 100755 --- a/01-setup.sh +++ b/01-setup.sh @@ -90,7 +90,8 @@ fi secho 3 "=== サイト設定" sudo a2dissite 000-default sudo cp apache/*.conf /etc/apache2/sites-available/ -sudo a2ensite example.net gitea kopano +sudo a2ensite example.net gitea kopano test +[ ! -d /var/www/test ] && sudo mkdir /var/www/test && sudo chown $(whoami):$(whoami) /var/www/test secho 3 "=== モジュールの有効化" sudo a2enmod ssl rewrite proxy_http headers diff --git a/10-hosts.sh b/10-hosts.sh index d4fffac..8568eb9 100755 --- a/10-hosts.sh +++ b/10-hosts.sh @@ -9,7 +9,7 @@ if [ -z $IPADDRESS ];then IPADDRESS="127.0.0.1" fi -DOMMEMBER="example\.net git\.example\.net mail\.example\.net smtp\.example\.net" +DOMMEMBER="example\.net git\.example\.net mail\.example\.net smtp\.example\.net test\.example\.net" if [ $(grep -c "$DOMMEMBER" /etc/hosts) -eq 0 ]; then sudo sed -i "\$a $IPADDRESS\t$DOMMEMBER" /etc/hosts else diff --git a/91-teardown.sh b/91-teardown.sh index 619d55b..d84114e 100755 --- a/91-teardown.sh +++ b/91-teardown.sh @@ -38,6 +38,7 @@ sudo rm /etc/apache2/sites-available/example.net.conf sudo rm /etc/apache2/sites-available/gitea.conf sudo rm /etc/apache2/sites-available/kopano.conf sudo rm /etc/apache2/conf-available/fqdn.conf +sudo rmdir /var/www/test sudo apt -y purge apache2 sudo apt -y autoremove diff --git a/apache/test.conf b/apache/test.conf new file mode 100644 index 0000000..93d59b0 --- /dev/null +++ b/apache/test.conf @@ -0,0 +1,22 @@ + + ServerName test.example.net + + RewriteEngine on + RewriteCond %{HTTPS} off + RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} + RewriteCond %{SERVER_NAME} =test.example.net + RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] + + + + ServerName test.example.net + ServerAdmin webmaster@example.net + DocumentRoot /var/www/test + + ErrorLog ${APACHE_LOG_DIR}/test-error.log + CustomLog ${APACHE_LOG_DIR}/test-access.log combined + + SSLEngine on + SSLCertificateFile /etc/ssl/private/wildcard.example.net.crt + SSLCertificateKeyFile /etc/ssl/private/wildcard.example.net.key +