Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENT-12151: Added possibility to configure Mission Portal web server ports #2947

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions cfe_internal/enterprise/CFE_hub_specific.cf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ bundle common cfe_internal_hub_vars

policy_server::

"http_port" -> { "ENT-12151" }
string => ifelse( isvariable("cfe_internal_hub_vars.http_port"), "$(cfe_internal_hub_vars.http_port)", "80" ),
comment => "Mission portal's webserver HTTP port. Default 80";

"https_port" -> { "ENT-12151" }
string => ifelse( isvariable("cfe_internal_hub_vars.https_port"), "$(cfe_internal_hub_vars.https_port)", "443" ),
comment => "Mission portal's webserver HTTPS port. Default 443";

"docroot" string => "$(sys.workdir)/httpd/htdocs",
comment => "Root directory of Enterprise Web interface",
handle => "cfe_internal_hub_vars_docroot";
Expand Down Expand Up @@ -91,6 +99,45 @@ bundle common cfe_internal_hub_vars

}

##################################################################
#
# update_cli_rest_server_url_config
# - updates REST server URL port of Mission Portal WebGUI when
# cfe_internal_hub_vars.https_port is changed
#
##################################################################
bundle agent update_cli_rest_server_url_config
{
vars:
# Both share and live versions must be changed at once since httpd will be restarted later in the same agent run.
"mp_config_file" string => "$(cfe_internal_hub_vars.docroot)/application/config/config.php";
aleksandrychev marked this conversation as resolved.
Show resolved Hide resolved
"mp_share_config_file" string => "$(sys.workdir)/share/GUI/application/config/config.php";
craigcomstock marked this conversation as resolved.
Show resolved Hide resolved
"regex_test_pattern" string => ".*localhost:$(cfe_internal_hub_vars.https_port).*";

files:
"$(mp_share_config_file)"
edit_line => change_cli_rest_server_url_port,
if => and(
fileexists("$(mp_share_config_file)"),
islessthan(countlinesmatching("$(regex_test_pattern)", "$(mp_share_config_file)"), 1)
);

"$(mp_config_file)"
nickanderson marked this conversation as resolved.
Show resolved Hide resolved
edit_line => change_cli_rest_server_url_port,
if => and(
fileexists("$(mp_config_file)"),
islessthan(countlinesmatching("$(regex_test_pattern)", "$(mp_config_file)"), 1)
);
}

bundle edit_line change_cli_rest_server_url_port
{
replace_patterns:
aleksandrychev marked this conversation as resolved.
Show resolved Hide resolved
"^\s*\$config\['cli_rest_server_url'\]\s*=\s*\"https://localhost(?::(?!$(cfe_internal_hub_vars.https_port))\d{1,5})?/api/\";\s*$"
replace_with => value(" $config['cli_rest_server_url'] = \"https://localhost:$(cfe_internal_hub_vars.https_port)/api/\";"),
comment => "Change port CLI REST server URL port";
}

##################################################################
#
# cfe_internal_update_folders
Expand Down
5 changes: 5 additions & 0 deletions cfe_internal/enterprise/mission_portal.cf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ bundle agent cfe_internal_enterprise_mission_portal
handle => "cfe_internal_management_web_server",
comment => "Manage Apache Web server (on/off)";

"Port Configuration" -> { "CFEngine Enterprise", "Mission Portal" }
nickanderson marked this conversation as resolved.
Show resolved Hide resolved
usebundle => update_cli_rest_server_url_config,
handle => "cfe_internal_management_update_cli_rest_server_url_config",
comment => "Update the REST server URL port in the Mission Portal when cfe_internal_hub_vars.https_port is changed";

}
bundle agent apachectl_patched_for_upgrade
# @brief Ensure that apacehctl is patched so that it is able to re-start services
Expand Down
8 changes: 4 additions & 4 deletions cfe_internal/enterprise/templates/httpd.conf.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ServerRoot "{{{vars.sys.workdir}}}/httpd"
# ENT-10646 - Listen 80 often causes IPv6 related errors, specifying ipv4 squashes them.
# Unclear why the same is not an issue for 443
# To enable listening on ipv6 add Listen [::]:80
Listen 0.0.0.0:80
Listen 0.0.0.0:{{{vars.cfe_internal_hub_vars.http_port}}}
{{/classes.cfe_enterprise_disable_plain_http}}

PidFile "{{{vars.mission_portal_apache_from_stage.httpd_pid_file}}}"
Expand Down Expand Up @@ -135,7 +135,7 @@ LogLevel warn
# This content used to be included from an external file
# /var/cfengine/httpd/conf/extra/httpd-ssl.conf

Listen 443
Listen {{{vars.cfe_internal_hub_vars.https_port}}}

AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
Expand Down Expand Up @@ -183,12 +183,12 @@ LogLevel warn
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

<VirtualHost _default_:443>
<VirtualHost _default_:{{{vars.cfe_internal_hub_vars.https_port}}}>
DocumentRoot "{{{vars.cfe_internal_hub_vars.public_docroot}}}"
Alias "/api" "{{{vars.cfe_internal_hub_vars.docroot}}}/api"
Alias "/api/static" "{{{vars.cfe_internal_hub_vars.docroot}}}/api/static"
Alias "/ldap" "{{{vars.cfe_internal_hub_vars.docroot}}}/ldap"
ServerName {{{vars.sys.fqhost}}}:443
ServerName {{{vars.sys.fqhost}}}:{{{vars.cfe_internal_hub_vars.https_port}}}
# ServerAdmin root@localhost
ErrorLog "{{{vars.cfe_internal_hub_vars.error_log}}}"
LogFormat "%h %l %{username}n %t \"%r\" %>s %b"
Expand Down
Loading