You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sw...@apache.org on 2016/06/28 15:28:46 UTC

[12/15] git commit: updated refs/heads/master to e4ba640

SysVM cloud-early-config: Intermediate fix for SecStore & CORS
* Take setup from vhost.template rather than default(-ssl)
  * should move into Python CS code as well
* Move CORS setup to separate conf
* Modify vhost template to Optionally include the cors file
* Add NameVirtualHost to vhost template for feature parity with ports.conf
* Take setup from vhost.template rather than default(-ssl)


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

Branch: refs/heads/master
Commit: 72e83085e1e041b9272baa18a6b212d61fbbde01
Parents: f49a4d9
Author: Ronald van Zantvoort <ro...@pcextreme.nl>
Authored: Mon May 30 18:25:42 2016 +0200
Committer: Wido den Hollander <wi...@widodh.nl>
Committed: Tue Jun 7 13:03:10 2016 +0200

----------------------------------------------------------------------
 .../debian/config/etc/apache2/vhost.template    |  4 +++
 .../debian/config/etc/init.d/cloud-early-config | 38 +++++++++-----------
 2 files changed, 20 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/72e83085/systemvm/patches/debian/config/etc/apache2/vhost.template
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/apache2/vhost.template b/systemvm/patches/debian/config/etc/apache2/vhost.template
index dd9c58a..24d8d60 100644
--- a/systemvm/patches/debian/config/etc/apache2/vhost.template
+++ b/systemvm/patches/debian/config/etc/apache2/vhost.template
@@ -83,6 +83,9 @@
 		Allow from 127.0.0.0/255.0.0.0 ::1/128
 	</Directory>
 
+    # Include CORS configuration if set
+    IncludeOptional /etc/apache2/cors.conf
+
 	#   SSL Engine Switch:
 	#   Enable/Disable SSL for this virtual host.
 	SSLEngine on
@@ -225,6 +228,7 @@
 # README.Debian.gz
 
 Listen 10.1.1.1:80
+NameVirtualHost 10.1.1.1:80
 
 <IfModule mod_ssl.c>
     # If you add NameVirtualHost *:443 here, you will also have to change

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/72e83085/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 baec1d8..8ced0f9 100755
--- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config
+++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
@@ -1212,33 +1212,27 @@ setup_secstorage() {
   fi
   setup_apache2 $ETH2_IP
 
+  # Deprecated, should move to Cs Python all of it
+  sed -e "s/<VirtualHost .*:80>/<VirtualHost $ETH2_IP:80>/" \
+    -e "s/<VirtualHost .*:443>/<VirtualHost $ETH2_IP:443>/" \
+    -e "s/Listen .*:80/Listen $ETH2_IP:80/g" \
+    -e "s/Listen .*:443/Listen $ETH2_IP:443/g" \
+    -e "s/NameVirtualHost .*:80/NameVirtualHost $ETH2_IP:80/g" /etc/apache2/vhost.template > /etc/apache2/sites-enabled/vhost-${ETH2_IP}.conf
+
   log_it "setting up apache2 for post upload of volume/template"
   a2enmod proxy
   a2enmod proxy_http
   a2enmod headers
 
-  SSL_FILE="/etc/apache2/sites-available/default-ssl"
-  PATTERN="RewriteRule ^\/upload\/(.*)"
-  CORS_PATTERN="Header set Access-Control-Allow-Origin"
-  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
-    if grep -q "$CORS_PATTERN" $SSL_FILE ; then
-      log_it "cors rules already exist in file $SSL_FILE"
-    else
-        log_it "adding cors rules to file: $SSL_FILE"
-        sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Origin \"*\" \n&/" $SSL_FILE
-        sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Methods \"POST, OPTIONS\" \n&/" $SSL_FILE
-        sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Headers \"x-requested-with, Content-Type, origin, authorization, accept, client-security-token, x-signature, x-metadata, x-expires\" \n&/" $SSL_FILE
-    fi
-  fi
+  cat >/etc/apache2/cors.conf <<CORS
+RewriteEngine On
+RewriteCond %{HTTPS} =on
+RewriteCond %{REQUEST_METHOD} =POST
+RewriteRule ^/upload/(.*) http://127.0.0.1:8210/upload?uuid=\$1 [P,L]
+Header always set Access-Control-Allow-Origin "*"
+Header always set Access-Control-Allow-Methods "POST, OPTIONS"
+Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, x-signature, x-metadata, x-expires"
+CORS
 
   service apache2 restart