From 0cdc16146c37119fa69b6f6984402f3ff0dbba07 Mon Sep 17 00:00:00 2001 From: Roque <roqueporchetto@gmail.com> Date: Fri, 23 Feb 2018 11:47:39 +0100 Subject: [PATCH] erp5: new parameters to set custom http and https virtualhost ports for frontend --- .../instance-slave-apache-input-schema.json | 10 ++++++++++ .../templates/default-virtualhost.conf.in | 4 ++-- software/erp5/instance-erp5-input-schema.json | 12 +++++++++++- stack/erp5/instance-erp5.cfg.in | 6 ++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/software/apache-frontend/instance-slave-apache-input-schema.json b/software/apache-frontend/instance-slave-apache-input-schema.json index f9e3a2fbb..3c50336ad 100644 --- a/software/apache-frontend/instance-slave-apache-input-schema.json +++ b/software/apache-frontend/instance-slave-apache-input-schema.json @@ -175,6 +175,16 @@ "default": "", "textarea": true, "type": "string" + }, + "virtualhostroot-http-port": { + "description": "Port where http requests to frontend will be redirected.", + "default": 80, + "type": "integer" + }, + "virtualhostroot-https-port": { + "description": "Port where https requests to frontend will be redirected.", + "default": 443, + "type": "integer" } } } diff --git a/software/apache-frontend/templates/default-virtualhost.conf.in b/software/apache-frontend/templates/default-virtualhost.conf.in index 9762e950e..6916d7a25 100644 --- a/software/apache-frontend/templates/default-virtualhost.conf.in +++ b/software/apache-frontend/templates/default-virtualhost.conf.in @@ -80,7 +80,7 @@ # First, we check if we have a zope backend server # If so, let's use Virtual Host Monster rewrite # We suppose that Apache listens to 443 (even indirectly thanks to things like iptables) - RewriteRule ^/(.*)$ {{ slave_parameter.get('https-url', slave_parameter.get('url', '')) }}/VirtualHostBase/https//%{SERVER_NAME}:443/{{ slave_parameter.get('path', '') }}/VirtualHostRoot/$1 [L,P] + RewriteRule ^/(.*)$ {{ slave_parameter.get('https-url', slave_parameter.get('url', '')) }}/VirtualHostBase/https//%{SERVER_NAME}:{{ slave_parameter.get('virtualhostroot-https-port', '443') }}/{{ slave_parameter.get('path', '') }}/VirtualHostRoot/$1 [L,P] {% elif slave_type == 'redirect' -%} RewriteRule (.*) {{ slave_parameter.get('https-url', slave_parameter.get('url', ''))}}$1 [R,L] {% else -%} @@ -159,7 +159,7 @@ # First, we check if we have a zope backend server # If so, let's use Virtual Host Daemon rewrite # We suppose that Apache listens to 80 (even indirectly thanks to things like iptables) - RewriteRule ^/(.*)$ {{ slave_parameter.get('url', '') }}/VirtualHostBase/http/%{SERVER_NAME}:80/{{ slave_parameter.get('path', '') }}/VirtualHostRoot/$1 [L,P] + RewriteRule ^/(.*)$ {{ slave_parameter.get('url', '') }}/VirtualHostBase/http/%{SERVER_NAME}:{{ slave_parameter.get('virtualhostroot-http-port', '80') }}/{{ slave_parameter.get('path', '') }}/VirtualHostRoot/$1 [L,P] {% else -%} {% if 'default-path' in slave_parameter %} RewriteRule ^/?$ {{ slave_parameter.get('default-path') }} [R=301,L] diff --git a/software/erp5/instance-erp5-input-schema.json b/software/erp5/instance-erp5-input-schema.json index ca7d0ee03..7a95360e0 100644 --- a/software/erp5/instance-erp5-input-schema.json +++ b/software/erp5/instance-erp5-input-schema.json @@ -88,7 +88,17 @@ "description": "Request a front-end slave instance of this software type.", "default": "RootSoftwareInstance", "type": "object" - } + }, + "virtualhostroot-http-port": { + "description": "Front-end slave http port. Port where http requests to frontend will be redirected.", + "default": 80, + "type": "integer" + }, + "virtualhostroot-https-port": { + "description": "Front-end slave https port. Port where https requests to frontend will be redirected.", + "default": 443, + "type": "integer" + } }, "type": "object" }, diff --git a/stack/erp5/instance-erp5.cfg.in b/stack/erp5/instance-erp5.cfg.in index 14e831522..aebd2d83d 100644 --- a/stack/erp5/instance-erp5.cfg.in +++ b/stack/erp5/instance-erp5.cfg.in @@ -301,6 +301,12 @@ slave = true {% if frontend_dict.get('domain') -%} {% do config_dict.__setitem__('custom_domain', frontend_dict['domain']) -%} {% endif -%} +{% if frontend_dict.get('virtualhostroot-http-port') -%} +{% do config_dict.__setitem__('virtualhostroot-http-port', frontend_dict['virtualhostroot-http-port']) -%} +{% endif -%} +{% if frontend_dict.get('virtualhostroot-https-port') -%} +{% do config_dict.__setitem__('virtualhostroot-https-port', frontend_dict['virtualhostroot-https-port']) -%} +{% endif -%} {% for name, value in config_dict.items() -%} config-{{ name }} = {{ value }} {% endfor -%} -- 2.30.9