enable_iframe for maas
diff --git a/maas/files/maas-http.conf b/maas/files/maas-http.conf
new file mode 100644
index 0000000..261720b
--- /dev/null
+++ b/maas/files/maas-http.conf
@@ -0,0 +1,41 @@
+<IfModule mod_ssl.c>
+ <VirtualHost *:443>
+ SSLEngine On
+ # Do not rely on these certificates, generate your own.
+ SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
+ SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
+ </VirtualHost>
+</IfModule>
+
+<IfModule mod_expires.c>
+ <Location /MAAS/>
+ ExpiresActive On
+ ExpiresByType text/javascript "access plus 1 hours"
+ ExpiresByType application/javascript "access plus 1 hours"
+ ExpiresByType application/x-javascript "access plus 1 hours"
+ ExpiresByType text/css "access plus 1 hours"
+ ExpiresByType image/gif "access plus 1 hours"
+ ExpiresByType image/jpeg "access plus 1 hours"
+ ExpiresByType image/png "access plus 1 hours"
+ </Location>
+</IfModule>
+
+<IfModule alias_module>
+ Alias /MAAS/static/ /usr/share/maas/web/static/
+</IfModule>
+
+<IfModule proxy_module>
+ ProxyPreserveHost on
+ ProxyPass /MAAS/ws "ws://localhost:5240/MAAS/ws"
+ ProxyPass /MAAS/static/ !
+ ProxyPass /MAAS/ http://localhost:5240/MAAS/
+ ProxyPass /MAAS http://localhost:5240/MAAS/
+</IfModule>
+
+<IfModule rewrite_module>
+ RewriteEngine On
+ # Redirect (permanently) requests for /MAAS to /MAAS/.
+ RewriteRule ^/MAAS$ %{REQUEST_URI}/ [R=301,L]
+</IfModule>
+Header set Access-Control-Allow-Origin "*"
+Header set X-Frame-Options "ALLOWALL"
diff --git a/maas/region.sls b/maas/region.sls
index 87a0fbc..7a81ac9 100644
--- a/maas/region.sls
+++ b/maas/region.sls
@@ -12,6 +12,36 @@
- require:
- pkg: maas_region_packages
+{%- if region.get('enable_iframe', False) %}
+
+/etc/apache2/conf-enabled/maas-http.conf:
+ file.managed:
+ - source: salt://maas/files/maas-http.conf
+ - user: root
+ - group: root
+ - mode: 644
+ - require:
+ - pkg: maas_region_packages
+ - require_in:
+ - service: maas_region_apache
+
+apache_headers_module:
+ apache_module.enabled:
+ - name: header
+ - require:
+ - pkg: maas_region_packages
+ - require_in:
+ - service: maas_region_apache
+
+maas_region_apache:
+ service.running:
+ - enable: true
+ - names: apache2
+ - watch:
+ - file: /etc/apache2/conf-enabled/maas-http.conf
+
+{%- endif %}
+
/etc/maas/preseeds/curtin_userdata_amd64_generic_trusty:
file.managed:
- source: salt://maas/files/curtin_userdata_amd64_generic_trusty
@@ -45,4 +75,4 @@
- require:
- service: maas_region_services
-{%- endif %}
\ No newline at end of file
+{%- endif %}
diff --git a/tests/pillar/maas_region.sls b/tests/pillar/maas_region.sls
index a3714a2..bd5690b 100644
--- a/tests/pillar/maas_region.sls
+++ b/tests/pillar/maas_region.sls
@@ -4,6 +4,7 @@
region:
host: localhost
role: master
+ enable_iframe: True
region:
bind:
host: localhost