Added option to handle Apache's HTTPS configuration
authorThierry Florac <tflorac@ulthar.net>
Thu, 27 Dec 2018 13:13:47 +0100
changeset 49 31b1b24e105c
parent 48 7d06fc8ea782
child 50 c0810f1e43c4
Added option to handle Apache's HTTPS configuration
cookiecutter.json
{{cookiecutter.project_slug}}/etc/apache2.2/{{cookiecutter.project_slug}}.conf
{{cookiecutter.project_slug}}/etc/apache2.4/{{cookiecutter.project_slug}}.conf
{{cookiecutter.project_slug}}/etc/development.ini
{{cookiecutter.project_slug}}/etc/production.ini
--- a/cookiecutter.json	Wed Nov 21 09:40:36 2018 +0100
+++ b/cookiecutter.json	Thu Dec 27 13:13:47 2018 +0100
@@ -3,6 +3,7 @@
   "project_name": "PyAMS",
   "project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
   "virtual_hostname": "{{ cookiecutter.project_slug }}.mydomain.com",
+  "use_https": true,
   "webapp_name": "webapp",
   "webapp_port": 6543,
   "eggs_directory": "eggs",
--- a/{{cookiecutter.project_slug}}/etc/apache2.2/{{cookiecutter.project_slug}}.conf	Wed Nov 21 09:40:36 2018 +0100
+++ b/{{cookiecutter.project_slug}}/etc/apache2.2/{{cookiecutter.project_slug}}.conf	Thu Dec 27 13:13:47 2018 +0100
@@ -5,6 +5,19 @@
 	ServerAdmin webmaster@localhost
 	ServerName {{ cookiecutter.virtual_hostname }}
 
+{%- if cookiecutter.use_https.lower() in ('true','on','yes','1') %}
+
+	RewriteEngine	on
+	RewriteRule		(.*)	https://{{ cookiecutter.virtual_hostname}}$1
+
+</VirtualHost>
+
+<VirtualHost *:443>
+
+	ServerAdmin webmaster@localhost
+	ServerName {{ cookiecutter.virtual_hostname }}
+{%- endif %}
+
 	DocumentRoot $((INSTALL))/var/htdocs
 	ErrorLog {{ cookiecutter.logs_directory }}/{{ cookiecutter.project_slug }}-error.log
 
@@ -28,4 +41,23 @@
 		Allow from all
 	</Directory>
 
+{%- if cookiecutter.use_notifications.lower() in ('true','on','yes','1') %}
+
+	RewriteEngine		on
+
+	RewriteCond		%{HTTP:Upgrade}	=websocket [NC]
+	RewriteRule		/(.*)			ws://{{ cookiecutter.pyams_ws_notify }}/$1	[P,L]
+{%- endif %}
+
+{%- if cookiecutter.use_https.lower() in ('true','on','yes','1') %}
+
+	SSLEngine		on
+{%- if cookiecutter.use_notifications.lower() in ('true','on','yes','1') %}
+	SSLProxyEngine		on
+{%- endif %}
+
+	SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
+	SSLCertificateKeyFile	/etc/ssl/private/ssl-cert-snakeoil.key
+{%- endif %}
+
 </VirtualHost>
--- a/{{cookiecutter.project_slug}}/etc/apache2.4/{{cookiecutter.project_slug}}.conf	Wed Nov 21 09:40:36 2018 +0100
+++ b/{{cookiecutter.project_slug}}/etc/apache2.4/{{cookiecutter.project_slug}}.conf	Thu Dec 27 13:13:47 2018 +0100
@@ -5,6 +5,19 @@
 	ServerAdmin webmaster@localhost
 	ServerName {{ cookiecutter.virtual_hostname }}
 
+{%- if cookiecutter.use_https.lower() in ('true','on','yes','1') %}
+
+	RewriteEngine	on
+	RewriteRule		(.*)	https://{{ cookiecutter.virtual_hostname}}$1
+
+</VirtualHost>
+
+<VirtualHost *:443>
+
+	ServerAdmin webmaster@localhost
+	ServerName {{ cookiecutter.virtual_hostname }}
+{%- endif %}
+
 	DocumentRoot $((INSTALL))/var/htdocs
 	ErrorLog {{ cookiecutter.logs_directory }}/{{ cookiecutter.project_slug }}-error.log
 
@@ -26,4 +39,23 @@
 		Require all granted
 	</Directory>
 
+{%- if cookiecutter.use_notifications.lower() in ('true','on','yes','1') %}
+
+	RewriteEngine		on
+
+	RewriteCond		%{HTTP:Upgrade}	=websocket [NC]
+	RewriteRule		/(.*)			ws://{{ cookiecutter.pyams_ws_notify }}/$1	[P,L]
+{%- endif %}
+
+{%- if cookiecutter.use_https.lower() in ('true','on','yes','1') %}
+
+	SSLEngine		on
+{%- if cookiecutter.use_notifications.lower() in ('true','on','yes','1') %}
+	SSLProxyEngine		on
+{%- endif %}
+
+	SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
+	SSLCertificateKeyFile	/etc/ssl/private/ssl-cert-snakeoil.key
+{%- endif %}
+
 </VirtualHost>
--- a/{{cookiecutter.project_slug}}/etc/development.ini	Wed Nov 21 09:40:36 2018 +0100
+++ b/{{cookiecutter.project_slug}}/etc/development.ini	Thu Dec 27 13:13:47 2018 +0100
@@ -231,9 +231,15 @@
 # pyams_content.config.forms_tool_factory = pyams_content.shared.form.manager.FormsManager
 # pyams_content.config.forms_tool_name = forms
 
+# pyams_content.config.resources_tool_factory = pyams_content.shared.resource.manager.ResourceManager
+# pyams_content.config.resources_tool_name = resources
+
 # pyams_content.config.news_tool_factory = pyams_content.shared.news.manager.NewsManager
 # pyams_content.config.news_tool_name = news
 
+# pyams_content.config.topics_tool_factory = pyams_content.shared.topic.manager.TopicManager
+# pyams_content.config.topics_tool_name = topics
+
 ## Shared contents configuration
 ## Default factories are defined into PyAMS_content package via factory adapters.
 ## You can override default factory by defining these settings or by providing your own adapters.
--- a/{{cookiecutter.project_slug}}/etc/production.ini	Wed Nov 21 09:40:36 2018 +0100
+++ b/{{cookiecutter.project_slug}}/etc/production.ini	Thu Dec 27 13:13:47 2018 +0100
@@ -226,9 +226,15 @@
 # pyams_content.config.forms_tool_factory = pyams_content.shared.form.manager.FormsManager
 # pyams_content.config.forms_tool_name = forms
 
+# pyams_content.config.resources_tool_factory = pyams_content.shared.resource.manager.ResourceManager
+# pyams_content.config.resources_tool_name = resources
+
 # pyams_content.config.news_tool_factory = pyams_content.shared.news.manager.NewsManager
 # pyams_content.config.news_tool_name = news
 
+# pyams_content.config.topics_tool_factory = pyams_content.shared.topic.manager.TopicManager
+# pyams_content.config.topics_tool_name = topics
+
 ## Shared contents configuration
 ## Default factories are defined into PyAMS_content package via factory adapters.
 ## You can override default factory by defining these settings or by providing your own adapters.