diff --git a/BINSCRIPTS.md b/BINSCRIPTS.md index 8569b7d..7818108 100644 --- a/BINSCRIPTS.md +++ b/BINSCRIPTS.md @@ -9,7 +9,7 @@ If you are reading this file in BINSCRIPTS.md, your container project is likely To use these scripts yourself, issue this command: ``` -curl "https://github.internet2.edu/raw/docker/util/master/bin/install.sh?token=AAAAEddkrL9MeeA6VWcNn_PgV30r4lD1ks5XogeiwA%3D%3D" | bash +curl "https://github.internet2.edu/raw/docker/util/master/bin/install.sh?token=AAAAE4VRBLPB8VExPHSR5nCe791IAYqaks5Xzug5wA%3D%3D" | bash ``` ### common.bash @@ -38,4 +38,4 @@ This will also install a Jenkinsfile to your repository, if it doesn't have one. ### Testing -#### test.sh \ No newline at end of file +#### test.sh diff --git a/Dockerfile b/Dockerfile index 41681b7..cd55b79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,8 +94,19 @@ VOLUME /opt/shibboleth/ssl/ # Required volumes for mounting Apache SSL files into container VOLUME /opt/httpd/ssl/ +#Added ssl default conf +RUN ln -s /opt/etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf + +#Added shib module apache +RUN ln -s /opt/etc/httpd/conf.modules.d/00-shib.conf /etc/httpd/conf.modules.d/00-shib.conf +RUN ln -s /usr/lib64/shibboleth/mod_shib_24.so /etc/httpd/modules/mod_shib_24.so + +#Add httpd configuration +RUN ln -s /opt/etc/httpd/conf.d/ports.conf /etc/httpd/conf.d/ports.conf +RUN ln -s /opt/etc/httpd/conf.d/handlers.conf /etc/httpd/conf.d/handlers.conf +RUN ln -s /opt/etc/httpd/conf.d/virtual_host_80.conf /etc/httpd/conf.d/00-comanage-80.conf # Port EXPOSE 80 443 -CMD ["/opt/bin/start.sh"] \ No newline at end of file +CMD ["/opt/bin/start.sh"] diff --git a/container_files/bin/configure_httpd.sh b/container_files/bin/configure_httpd.sh index d94aafe..c864f20 100755 --- a/container_files/bin/configure_httpd.sh +++ b/container_files/bin/configure_httpd.sh @@ -1,5 +1,23 @@ #!/bin/bash log="/tmp/httpd.log" +date >> $log +echo "Configuring httpd: " >> $log -echo "Configuring httpd: " > $log \ No newline at end of file +sed -i "s|COMANAGE_SERVER_FQDN|$COMANAGE_SERVER_FQDN|g" /opt/etc/httpd/conf.d/virtual_host_80.conf >> $log +sed -i "s|COMANAGE_SERVER_FQDN|$COMANAGE_SERVER_FQDN|g" /opt/etc/httpd/conf.d/virtual_host_443.conf >> $log +if [[ $CHANGE_TO_SSL_HTTPD_KEY && ${CHANGE_TO_SSL_HTTPD_KEY-x} ]]; then + sed -i "s|CHANGE_TO_SSL_HTTPD_KEY|$CHANGE_TO_SSL_HTTPD_KEY|g" /opt/etc/httpd/conf.d/virtual_host_443.conf >> $log +else + echo "CHANGE_TO_SSL_HTTPD_KEY variable is not used" >> $log +fi +if [[ $CHANGE_TO_SSL_HTTPD_CERT && ${CHANGE_TO_SSL_HTTPD_CERT-x} ]]; then + sed -i "s|CHANGE_TO_SSL_HTTPD_CERT|$CHANGE_TO_SSL_HTTPD_CERT|g" /opt/etc/httpd/conf.d/virtual_host_443.conf >> $log +else + echo "CHANGE_TO_SSL_HTTPD_CERT variable is not used" >> $log +fi + +echo "Removing Listen 80 in httpd.conf" >> $log +sed -i 's/^Listen 80$//' /etc/httpd/conf/httpd.conf +date >> $log +echo "Configuration of httpd completed " >> $log diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh index 29c15e6..c778966 100755 --- a/container_files/bin/start.sh +++ b/container_files/bin/start.sh @@ -15,8 +15,8 @@ then else echo "COmanage was configured" >>$log echo "COmanage was configured" - echo "Starting apache" >>$log - echo "Starting apache" + echo "Starting apache and shibd" >>$log + echo "Starting apache shibd" /usr/local/bin/httpd-shib-foreground fi else @@ -24,10 +24,26 @@ else date >> $log echo "Testing connectivity to database before continue with install" >> $log echo "Testing connectivity to database before continue with install" - /opt/wait-for-it/wait-for-it.sh $MYSQL_HOST:3306 -t $WAIT_TIME --strict -- /opt/bin/main.sh - + /opt/wait-for-it/wait-for-it.sh $MYSQL_HOST:3306 -t $WAIT_TIME --strict -- /opt/bin/main.sh >> $log + echo "Mariadb default port is open and test connection ok" + echo "Mariadb default port is open and test connection ok" >> $log + echo "Testing connectivy to database before continue with install" >> $log + echo "Testing connectivy to database before continue with install" + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" + laststatus="$?" + echo "checking connectivity" >> $log + while [ "$laststatus" != "0" ]; do + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" + laststatus="$?" + sleep 5 + date >> $log + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" >> $log + done + echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" >> $log + echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" date >> $log - echo "Starting apache" >>$log - echo "Starting apache" + echo "Starting apache and shibd" >>$log + echo "Starting apache shibd" /usr/local/bin/httpd-shib-foreground fi diff --git a/container_files/etc/httpd/conf.d/handlers.conf b/container_files/etc/httpd/conf.d/handlers.conf new file mode 100644 index 0000000..e094143 --- /dev/null +++ b/container_files/etc/httpd/conf.d/handlers.conf @@ -0,0 +1,3 @@ +AddType text/html .php +php_value session.save_handler "files" +php_value session.save_path "/var/lib/php/session" diff --git a/container_files/etc/httpd/conf.d/ports.conf b/container_files/etc/httpd/conf.d/ports.conf new file mode 100644 index 0000000..cf2b7d0 --- /dev/null +++ b/container_files/etc/httpd/conf.d/ports.conf @@ -0,0 +1,2 @@ +Listen 80 http +Listen 443 https diff --git a/container_files/etc/httpd/conf.d/ssl.conf b/container_files/etc/httpd/conf.d/ssl.conf new file mode 100644 index 0000000..ccc067c --- /dev/null +++ b/container_files/etc/httpd/conf.d/ssl.conf @@ -0,0 +1,6 @@ +SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog +SSLSessionCache shmcb:/run/httpd/sslcache(512000) +SSLSessionCacheTimeout 300 +SSLRandomSeed startup file:/dev/urandom 256 +SSLRandomSeed connect builtin +SSLCryptoDevice builtin diff --git a/container_files/etc/httpd/conf.d/comanage.conf b/container_files/etc/httpd/conf.d/virtual_host_443.conf similarity index 76% rename from container_files/etc/httpd/conf.d/comanage.conf rename to container_files/etc/httpd/conf.d/virtual_host_443.conf index 0b8e83a..28d17ea 100644 --- a/container_files/etc/httpd/conf.d/comanage.conf +++ b/container_files/etc/httpd/conf.d/virtual_host_443.conf @@ -1,25 +1,3 @@ -Listen 80 http -Listen 443 https - -AddType text/html .php -php_value session.save_handler "files" -php_value session.save_path "/var/lib/php/session" - -LoadModule mod_shib /usr/lib64/shibboleth/mod_shib_24.so - - -ServerName http://COMANAGE_SERVER_FQDN:80 -UseCanonicalName On -RedirectMatch (.*) https://COMANAGE_SERVER_FQDN$1 - - -SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog -SSLSessionCache shmcb:/run/httpd/sslcache(512000) -SSLSessionCacheTimeout 300 -SSLRandomSeed startup file:/dev/urandom 256 -SSLRandomSeed connect builtin -SSLCryptoDevice builtin - ServerName https://COMANAGE_SERVER_FQDN:443 UseCanonicalName On @@ -103,5 +81,4 @@ Redirect "/registry/users/logout" "https://COMANAGE_SERVER_FQDN/Shibboleth.sso/L Require all denied - - + diff --git a/container_files/etc/httpd/conf.d/virtual_host_80.conf b/container_files/etc/httpd/conf.d/virtual_host_80.conf new file mode 100644 index 0000000..ffe62ec --- /dev/null +++ b/container_files/etc/httpd/conf.d/virtual_host_80.conf @@ -0,0 +1,5 @@ + +ServerName http://COMANAGE_SERVER_FQDN:80 +UseCanonicalName On +RedirectMatch (.*) https://COMANAGE_SERVER_FQDN$1 + diff --git a/container_files/etc/httpd/conf.modules.d/00-shib.conf b/container_files/etc/httpd/conf.modules.d/00-shib.conf new file mode 100644 index 0000000..0e5c7b2 --- /dev/null +++ b/container_files/etc/httpd/conf.modules.d/00-shib.conf @@ -0,0 +1 @@ +LoadModule mod_shib /usr/lib64/shibboleth/mod_shib_24.so