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-10411: Added ability to disable plain http for Mission Portal #2688

Merged
merged 2 commits into from
Jul 24, 2023
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
49 changes: 49 additions & 0 deletions MPF.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,55 @@ manage High Availability of Enterprise Hubs is enabled.

**Note:** This class is **not** defined by default.

### Disable plain http for CFEngine Enterprise Mission Portal

By default Mission Portal listens for HTTP requests on port 80, redirecting to HTTPS on port 443. To prevent the web server from listening on port 80 at all define `default:cfe_cfengine_enterprise_disable_plain_http`.

**For example:**

```json
{
"classes": {
"default:cfe_enterprise_disable_plain_http": {
"class_expressions": [ "am_policy_hub|policy_server::" ]
}
}
}
```

**Notes:**

- If this class (`default:cfe_enterprise_disable_http_redirect_to_https`) is defined the class `default:cfe_enterprise_disable_plain_http` is defined is automatically defined.

**History:**

- Added in CFEngine 3.23.0

### Disable plain http redirect to https for CFEngine Enterprise Mission Portal
nickanderson marked this conversation as resolved.
Show resolved Hide resolved

By default Mission Portal listens for HTTP requests on port 80, redirecting to HTTPS on port 443. To prevent redirection of requests on HTTP to HTTPS define `default:cfe_enterprise_disable_http_redirect_to_https`.

**For example:**

```json
{
"classes": {
"default:cfe_enterprise_disable_http_redirect_to_https": {
"class_expressions": [ "(am_policy_hub|policy_server).test_server::" ]
}
}
}
```

**Notes:**

- If `default:cfe_enterprise_disable_plain_http` is defined, this class (`default:cfe_enterprise_disable_http_redirect_to_https`) is automatically defined.

**History:**

- Added in CFEngine 3.6.0
- Class renamed from `cfe_cfengine_enterprise_enable_plain_http` to `cfe_enterprise_disable_http_redirect_to_https` in CFEngine 3.23.0

### Disable cf\_promises\_validated check

For non policy hubs the default update policy only performs a full scan of
Expand Down
8 changes: 6 additions & 2 deletions cfe_internal/enterprise/templates/httpd.conf.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ ServerSignature Off
ServerTokens ProductOnly
ServerName {{{vars.sys.fqhost}}}
ServerRoot "{{{vars.sys.workdir}}}/httpd"
{{#classes.cfe_enterprise_disable_plain_http}}
# ENT-10411
Listen 80
{{/classes.cfe_enterprise_disable_plain_http}}

PidFile "{{{vars.mission_portal_apache_from_stage.httpd_pid_file}}}"

# Modules
Expand Down Expand Up @@ -230,11 +234,11 @@ AddType application/x-httpd-php-source php{{{vars.cfe_internal_hub_vars.php_v
<IfModule rewrite_module>
RewriteEngine On

{{^classes.cfe_enterprise_enable_plain_http}}
{{^classes.cfe_enterprise_disable_http_redirect_to_https}}
# Force https with redirection
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
{{/classes.cfe_enterprise_enable_plain_http}}
{{/classes.cfe_enterprise_disable_http_redirect_to_https}}

{{#classes.mission_portal_index_php_redirect_enabled}}
# redirect from `index.php/path` to `/path`
Expand Down
15 changes: 15 additions & 0 deletions controls/def.cf
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,21 @@ bundle common def
# Enable paths to POSIX tools instead of native tools when possible.
"mpf_stdlib_use_posix_utils" expression => "any";

enterprise_edition.(policy_server|am_policy_hub)::
"cfe_enterprise_disable_http_redirect_to_https"
scope => "namespace",
expression => "cfe_cfengine_enterprise_enable_plain_http";

"cfe_enterprise_disable_http_redirect_to_https"
expression => "cfe_enterprise_disable_plain_http",
comment => "If plain http is disabled, it makes no sense to redirect to it, so we disable that as well.";

reports:
"Warning: the 'cfe_cfengine_enterprise_enable_plain_http' class has been deprecated in favor of 'cfe_enterprise_disable_http_redirect_to_https', please adjust accordingly. The 'cfe_enterprise_disable_http_redirect_to_https' class has been set automatically."
if => "cfe_enterprise_disable_http_redirect_to_https.cfe_cfengine_enterprise_enable_plain_http";
"Warning: the 'cfe_cfengine_enterprise_enable_plain_http' class has been deprecated in favor of 'cfe_enterprise_disable_http_redirect_to_https', please adjust accordingly."
if => "cfe_cfengine_enterprise_enable_plain_http.!cfe_enterprise_disable_http_redirect_to_https";

}

bundle common inventory_control
Expand Down