Skip to content

Local settings for Drupal 8 and TYPO3 need to support trusted_host patterns (and with https) #680

Closed

Description

@tmotyl

What happened (or feature request):

When installing TYPO3 9 for the first time on ddev using https, an warning is thrown during installation wizard.

Trusted hosts pattern mismatch
The trusted hosts pattern will be configured to allow all header values. This is because your $SERVER_NAME:[defaultPort] is "typo3-master-intro.ddev.local:443" while your HTTP_HOST:SERVER_PORT is "typo3-master-intro.ddev.local:80". Check the pattern defined in Install Tool -> All configuration -> System -> trustedHostsPattern and adapt it to expected host value(s).

image

What you expected to happen:

No warning - as it is when installing using http.

How to reproduce this:

clone TYPO3 repo, run composer install, ddev config, ddev start, and follow the install wizard

Version: Please include the output of ddev version, docker version and the project's .ddev/config.yaml.

The issue exists in both default image and the new:
drud/nginx-php-fpm-local:20180224_multi_cms_nginx

Anything else do we need to know:

Related source links or issues:

Please use a complexity rating of 1-5 (5 is high) for a feature request. (High complexity implies more PR planning)

Activity

  1. rfay commented on Feb 27, 2018

    @rfay
    Member

    @tmotyl isn't this a TYPO3 issue, not ddev?

    Or would it be possible to add some context in the AdditionalConfiguration.php that would work around this?

  2. tmotyl commented on Feb 28, 2018

    @tmotyl
    ContributorAuthor

    this is a sign of a suboptimal server config.
    The trustedhostsPattern setting was introduced to mitigate "Host Spoofing" security issue
    https://typo3.org/teams/security/security-bulletins/typo3-core/typo3-core-sa-2014-001/
    "
    TYPO3 checks the currently submitted host-header against the SERVER_NAME variable.
    The SERVER_NAME variable contains trusted values in the following cases:
    Nginx Webserver: Nginx is set up with different servers blocks while the TYPO3 installation is not part of the "catch all" server block. By default only the first value of the server_name option is taken into account to populate the SERVER_NAME variable. If you specified more than one server name in your Nginx configuration you have to additionally add the following configuration:
    fastcgi_param SERVER_NAME $host;
    "
    In this case I see that SERVER_NAME seems correct, however the port is the issue.

  3. rfay commented on Feb 28, 2018

    @rfay
    Member

    Drupal8 has $settings['trusted_host_patterns'], https://www.drupal.org/node/1992030 - And it allows a regex. We absolutely need to add that to the settings.local.php for D8. But there you can add just

    $settings['trusted_host_patterns'] = [
      'ddev\.local$',
    ];
    

    and life is good, and of course you can add multiple patterns.

    I'm quite sure that we can support TYPO3 the same way with $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] right? Does it take a regex, can we just add a regex in AdditionalConfiguration.php that glosses over the port number and such?

  4. changed the title [-]Warning when installing TYPO3 9 with HTTPS[/-] [+]Local settings for Drupal 8 and TYPO3 needs to support trusted_host patterns (and with https)[/+] on Feb 28, 2018
  5. changed the title [-]Local settings for Drupal 8 and TYPO3 needs to support trusted_host patterns (and with https)[/-] [+]Local settings for Drupal 8 and TYPO3 need to support trusted_host patterns (and with https)[/+] on Feb 28, 2018
  6. tmotyl commented on Feb 28, 2018

    @tmotyl
    ContributorAuthor

    Yes, TYPO3 also allows you to use regex in $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'], and yes, you can add it to the AdditionalConfiguration. However if sever config is fully correct, you don't have to modify trustedHostsPattern.

    So as a workaround we can set in AdditionalConfiguratuion sth like (untested):

    $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*\.ddev\.local';
    
  7. rfay commented on Feb 28, 2018

    @rfay
    Member

    Right, but we'd want ddev with typo3 to work with both http and https right? Can that even be done without adding to the trustedHostsPattern?

  8. rfay commented on Mar 28, 2018

    @rfay
    Member

    Another note from @helhum about typo3:

    The issue here is the following:
    With the default configuration, TYPO3 looks, whether the HTTP Header "Host" matches the SERVER_NAME, assuming the latter cannot be modified.

    That check passes. But there is another check.

    It is checked whether the port passed with the HTTP Header, also matches SERVER_PORT.

    If no port was passed, default ports are assumed

    if HTTPS is on (determined from Env, or proxy settings), then default port is assumed to be 443, otherwise 80

    Now with ddev (and other ssl terminating setups), the backend server is never requested via HTTPS, but with HTTP and thus port 80 is used.

    But apparently, HTTPS is set to "on".

    To TYPO3 this now looks like a fake/invalid request (HTTPS without port set, cannot be requested over port 80) and it is rejected

    More on https://typo3.slack.com/archives/C8TRNQ601/p1522263659000324?thread_ts=1522226950.000339&cid=C8TRNQ601

  9. changed the title [-]Local settings for Drupal 8 and TYPO3 need to support trusted_host patterns (and with https)[/-] [+]Critical: Local settings for Drupal 8 and TYPO3 need to support trusted_host patterns (and with https)[/+] on Mar 29, 2018
  10. self-assigned this
    on Mar 30, 2018
  11. added this to the v0.17.0 milestone on Mar 30, 2018
  12. rickmanelius commented on Mar 30, 2018

    @rickmanelius
    Contributor

    Escalating the priority given that this is causing bigger issues with our TYPO3 (summarized by @tmotyl in the issue summary). A couple of other notes with @rfay. This may require additional help from the TYPO3 community. Currently, this may require either 1) moving the port inside the web container back to port 80 (there are still problems with this) or 2) modifications to the default TYPO3 nginx configuration.

  13. changed the title [-]Critical: Local settings for Drupal 8 and TYPO3 need to support trusted_host patterns (and with https)[/-] [+]Local settings for Drupal 8 and TYPO3 need to support trusted_host patterns (and with https)[/+] on Apr 2, 2018
  14. 10 remaining items

  15. decafdennis commented on May 7, 2018

    @decafdennis

    +1 on this: it would be nice if the Drupal 8 auto-generated settings.local.php had a correct trusted_host_patterns value so that we don't need to add the *.ddev.local domain to our version-controlled settings.php.

  16. rfay commented on May 7, 2018

    @rfay
    Member

    Thanks for your vote, we'll have it before long, it's so easy. And PRs are welcome.

  17. modified the milestones: v0.18.0, v0.19.0 on May 7, 2018
  18. removed this from the v0.19.0 milestone on May 29, 2018
  19. modified the milestone: v1.0.0 on Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions