You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2015/01/29 12:45:55 UTC

[6/6] git commit: updated refs/heads/volume-upload to e08522d

volume upload: adding the rewrite rules on start of cloud service


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e08522db
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e08522db
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e08522db

Branch: refs/heads/volume-upload
Commit: e08522dbaa035077c04db618e8e4a7491e6fd94b
Parents: 7231daa
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Thu Jan 29 16:26:55 2015 +0530
Committer: Rajani Karuturi <ra...@gmail.com>
Committed: Thu Jan 29 16:55:30 2015 +0530

----------------------------------------------------------------------
 .../etc/apache2/sites-available/default-ssl       |  5 -----
 .../debian/config/etc/init.d/cloud-early-config   | 18 +++++++++++++++++-
 systemvm/scripts/config_ssl.sh                    | 15 +++++++++++++++
 3 files changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e08522db/systemvm/patches/debian/config/etc/apache2/sites-available/default-ssl
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/apache2/sites-available/default-ssl b/systemvm/patches/debian/config/etc/apache2/sites-available/default-ssl
index 4cd2b16..0eea44d 100644
--- a/systemvm/patches/debian/config/etc/apache2/sites-available/default-ssl
+++ b/systemvm/patches/debian/config/etc/apache2/sites-available/default-ssl
@@ -168,10 +168,5 @@
 	# MSIE 7 and newer should be able to use keepalive
 	BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
 
-	RewriteEngine Off
-	RewriteCond %{HTTPS} =on
-	RewriteCond %{REQUEST_METHOD} =POST
-	RewriteRule ^/upload/(.*) http://127.0.0.1:8210/upload?uuid=$1 [P,L]
-
 </VirtualHost>
 </IfModule>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e08522db/systemvm/patches/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-config b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
index e835a7e..acd1172 100755
--- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config
+++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
@@ -1155,9 +1155,25 @@ setup_secstorage() {
     setup_sshd $ETH0_IP "eth0"
   fi
   setup_apache2 $ETH2_IP
+
+  log_it "setting up apache2 for post upload of volume/template"
   a2enmod proxy
   a2enmod proxy_http
-  [ -f /etc/apache2/sites-available/default-ssl ] && sed -i -e "s/RewriteEngine Off/RewriteEngine On/" /etc/apache2/sites-available/default-ssl
+
+  SSL_FILE="/etc/apache2/sites-available/default-ssl"
+  PATTERN="RewriteRule ^\/upload\/(.*)"
+  if [ -f $SSL_FILE ]; then
+    if grep -q "$PATTERN" $SSL_FILE ; then
+      log_it "rewrite rules already exist in file $SSL_FILE"
+    else
+        log_it "adding rewrite rules to file: $SSL_FILE"
+        sed -i -e "s/<\/VirtualHost>/RewriteEngine On \n&/" $SSL_FILE
+        sed -i -e "s/<\/VirtualHost>/RewriteCond %{HTTPS} =on \n&/" $SSL_FILE
+        sed -i -e "s/<\/VirtualHost>/RewriteCond %{REQUEST_METHOD} =POST \n&/" $SSL_FILE
+        sed -i -e "s/<\/VirtualHost>/RewriteRule ^\/upload\/(.*) http:\/\/127.0.0.1:8210\/upload?uuid=$1 [P,L] \n&/" $SSL_FILE
+    fi
+  fi
+
   service apache2 restart
 
   disable_rpfilter

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e08522db/systemvm/scripts/config_ssl.sh
----------------------------------------------------------------------
diff --git a/systemvm/scripts/config_ssl.sh b/systemvm/scripts/config_ssl.sh
index 6971055..2ef200e 100755
--- a/systemvm/scripts/config_ssl.sh
+++ b/systemvm/scripts/config_ssl.sh
@@ -58,6 +58,21 @@ config_apache2_conf() {
   then
     sed -i -e "s/#SSLCertificateChainFile.*/SSLCertificateChainFile \/etc\/ssl\/certs\/cert_apache_chain.crt/" /etc/apache2/sites-available/default-ssl
   fi
+
+  SSL_FILE="/etc/apache2/sites-available/default-ssl"
+  PATTERN="RewriteRule ^\/upload\/(.*)"
+  if [ -f $SSL_FILE ]; then
+    if grep -q "$PATTERN" $SSL_FILE ; then
+      echo "rewrite rules already exist in file $SSL_FILE"
+    else
+        echo "adding rewrite rules to file: $SSL_FILE"
+        sed -i -e "s/<\/VirtualHost>/RewriteEngine On \n&/" $SSL_FILE
+        sed -i -e "s/<\/VirtualHost>/RewriteCond %{HTTPS} =on \n&/" $SSL_FILE
+        sed -i -e "s/<\/VirtualHost>/RewriteCond %{REQUEST_METHOD} =POST \n&/" $SSL_FILE
+        sed -i -e "s/<\/VirtualHost>/RewriteRule ^\/upload\/(.*) http:\/\/127.0.0.1:8210\/upload?uuid=$1 [P,L] \n&/" $SSL_FILE
+    fi
+  fi
+
 }
 
 copy_certs() {