Skip to content

Implement traefik as optional/future ddev-router, fixes #3458, fixes #2653 - #4248

Merged
rfay merged 94 commits into
ddev:masterfrom
rfay:20220918_traefik
Nov 23, 2022
Merged

rfay merged 94 commits into
ddev:masterfrom
rfay:20220918_traefik

Conversation

@rfay

@rfay rfay commented Oct 2, 2022 •

Copy link
Copy Markdown
Member

The Problem/Issue/Bug:

How this PR Solves The Problem:

Lots of work
No longer binding docker.sock

TODO

  • Tests (below)
  • Support wildcards, see TestConfigValidate()
  • Get it to run as an unprivileged user
  • Fix “ddev-router Pulling…ddev-router Error” in startup (Windows)
  • Lets Encrypt support for casual webhosting (this may wait)
  • Handle HTTP_EXPOSE port non-pair like "8200" and assume it to be "8200:8200"
  • Make sure ddev stop removes project configuration from the ddev-global-cache/traefik/config directory, so it disappears from the traefik dashboard.
  • Support VIRTUAL_HOST (multiple hostnames) and use those for our routing list
  • Add global project_tld into traefik default cert and wildcard into project cert (after Implementation of global project-tld config option #4218 lands)
  • Make sure it's possible to disable HTTP2
  • Make sure the default cert works
  • Implement a far better way to check for #ddev-generated (in another PR)
  • custom_certs shouldn't permanently override .ddev/traefik/certs - should they even get copied in there?
  • Clean up duplicate HTTP_EXPOSE/HTTPS_EXPOSE code
  • Why do we push global and project config in two separate actions?
  • Turn failfast back on in traefik tests in github actions

DOCS

  • Custom certs (they now just replace the ddev-generated certs in project)
  • Traefik dashboard on localhost:9999
  • Add traefik directory to "What's in .ddev directory"
  • How to manually override project and global traefik config
  • docker logs ddev-router

Manual Testing Instructions:

  • ddev poweroff && ddev config global --use-traefik

Automated Testing Overview:

  • Add an additional github test that uses traefik for everything
  • Add explicit tests that do a bit of testing on every platform.

Related Issue Link(s):

Release/Deployment notes:

@rfay
rfay requested review from cmuench and jonaseberle October 2, 2022 23:04
@github-actions

github-actions Bot commented Oct 2, 2022 •

Copy link
Copy Markdown

@cmuench

cmuench commented Oct 3, 2022

Copy link
Copy Markdown
Collaborator

@rfay wow. You already did the implementation. I will try that out ASAP

@cmuench

cmuench commented Oct 4, 2022

Copy link
Copy Markdown
Collaborator

@rfay Just started with some tests. First look is awesome. For the test I selected a project which communicates to another ddev project. Seems to work.
One thing I found is that already removed projects are still in the Traefik Dashboard.

@cmuench

cmuench commented Oct 4, 2022 •

Copy link
Copy Markdown
Collaborator

@rfay Just started a Magento 2 project with Kibana and Elasticsearch. The Kibana is then listed in the Traefik Dashboard and can be accessed. The Elasticsearch Server is not listed.
ddev status shows the port of both services.

CLI shows a warning message:

Skipping bad HTTP_EXPOSE port pair spec 9200 for service elasticsearch

@rfay

rfay commented Oct 4, 2022 •

Copy link
Copy Markdown
Member Author

Skipping bad HTTP_EXPOSE port pair spec 9200 for service elasticsearch

Ah, the code assumes that the port pair will be a port pair, but a single port has always been acceptable (though rarely used). Thanks for pointing this out.

ddev stop should probably remove config from the router, I'll check that. I think it removes it from the project files (.ddev/traefik) but don't think it actually makes that change in the docker volume that traefik is looking at.

(Added those two things to the checklist)

@rfay
rfay force-pushed the 20220918_traefik branch 4 times, most recently from 064ccd4 to ea85e05 Compare November 16, 2022 16:30
@rfay
rfay marked this pull request as ready for review November 17, 2022 20:42
@rfay
rfay requested a review from mattstein November 17, 2022 20:45

@mattstein mattstein left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a dazzling pile of suggestions I doubt will surprise you! ✨😄


The job of the `ddev-router` is to receive most HTTP or HTTPS traffic, like requests to `*.ddev.site`, and deliver it to the correct project's web container, see [Container Architecture](../basics/architecture.md#container-architecture). The router as of DDEV v1.21.3 was always a forked, poorly documented nginx reverse proxy container.

The very popular [Traefik Proxy](https://traefik.io/traefik/) will replace the current `ddev-router` in the future, but is available as an experimental configuration today. Feedback is welcome. To enable it:

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! I misread that as ddev-router starting with its current forked nginx proxy in v1.21.3.

Your edit fixes my mistake, but also seems to suggest that in DDEV v1.21.3 ddev-router is no longer based on that nginx fork—but it still is by default if I’m understanding correctly. I edited my suggestion above to clarify that 1.21.3 adds an opt-in Traefik option that will become the default in some future release:

The default ddev-router is based on a forked, poorly-documented nginx reverse proxy. A future release will replace this with the popular Traefik Proxy, available in DDEV v1.21.3 as an experimental feature. Run the following to enable it:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and one more revision to try and clarify that 1.21.3 adds a new option for the first time. It’s weird to start the paragraph calling it a “default” when it’s been the only option before this new introduction:

ddev-router has been based on a forked, poorly-documented nginx reverse proxy. DDEV v1.21.3 adds a new router based on the popular Traefik Proxy, available as an experimental feature until it becomes the default in a future release. Run the following to enable it:

Updated my suggestion above and I promise I’ll leave it alone now.

@rfay rfay left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much!

@rfay rfay changed the title Implement traefik as ddev-router, fixes #3458, fixes #2653 Implement traefik as optional/future ddev-router, fixes #3458, fixes #2653 Nov 21, 2022
rfay and others added 26 commits November 22, 2022 17:18
1. It was generating certs and thus generating the CAROOT
2. When not doing HTTPS it shouldn't do either of those in the first place
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants