-
Notifications
You must be signed in to change notification settings - Fork 82
Reverse proxy in DDEV cluster #2999
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
base: 5.0
Are you sure you want to change the base?
Changes from all commits
2f79384
a8d4f45
07c16c7
edd500e
04cbbfc
d55279f
12058fd
565b58b
edc40d6
fb8644b
5f028d2
1aad23b
ce983eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,119 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| To run an [[= product_name_cloud =]] project locally, you may refer to [DDEV and Ibexa Cloud](ddev_and_ibexa_cloud.md) instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Install reverse proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Varnish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The following sequence of commands: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Set some variables to distinguish Varnish versions, here for Varnish 7.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. Copy and customize VCL files in `.ddev/varnish/` (which is mounted as `/etc/varnish/` into the container) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - set `web` container has the backend host and an invalidator (so back office can purge cache) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - add "all IPs" CIDR notation to `debuggers` list to allow debugging info from any IP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - on Varnish 7, enable logging of access control list matching for both `invalidators` and `debuggers` lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (new Varnish 7 syntax, it was enabled by default on previous versions) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. Set the Varnish version to use and its demon starting parameters to use the files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4. Adds the Varnish container | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5. Sets Varnish as the HTTP cache server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6. Restarts the DDEV cluster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VARNISH_VERSION=7.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vcl_path=vcl_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vcl_file=varnish7.vcl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p .ddev/varnish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp vendor/ibexa/http-cache/docs/varnish/vcl/$vcl_file .ddev/varnish/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed 's/.host = "127.0.0.1";/.host = "web";/' vendor/ibexa/http-cache/docs/varnish/vcl/parameters.vcl > .ddev/varnish/parameters.vcl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i '/^acl invalidators {$/a \\ "web";' .ddev/varnish/parameters.vcl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i '/^acl debuggers {$/a \\ "0.0.0.0"/0; \/\/ debug from any IP' .ddev/varnish/parameters.vcl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ $VARNISH_VERSION == 7.* ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i 's/acl invalidators {/acl invalidators +log {/' .ddev/varnish/parameters.vcl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i 's/acl debuggers {/acl debuggers +log {/' .ddev/varnish/parameters.vcl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev dotenv set .ddev/.env.varnish --varnish-docker-image=varnish:$VARNISH_VERSION --varnish-varnishd-params " -p $vcl_path=/etc/varnish -f /etc/varnish/$vcl_file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+60
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And update step descriptions accordingly |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev get ddev/ddev-varnish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev config --web-environment-add HTTPCACHE_PURGE_SERVER=http://varnish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev config --web-environment-add HTTPCACHE_PURGE_TYPE=varnish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev config --web-environment-add TRUSTED_PROXIES=varnish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev restart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| To use Varnish 6.0LTS, set the following variables instead: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VARNISH_VERSION=6.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vcl_path=vcl_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vcl_file=varnish6.vcl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+77
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When minor variables are moved to the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If you're using [Apache as web server](install_with_ddev.md#switch-to-apache-and-its-virtual-host), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| you must set `varnish` as a trusted proxy in `.ddev/apache/apache-site.conf` before restarting DDEV: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i 's/#SetEnv TRUSTED_PROXIES ""/SetEnv TRUSTED_PROXIES "varnish"/' .ddev/apache/apache-site.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev restart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The Varnish server replace the web server in some places. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If you run `ddev describe`, you can see that Varnish is now the one responding to DDEV domain `.ddev.site` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while the web server still replies to `127.0.0.1` with its own ports. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You can see Varnish headers in HTTP responses, for example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```console | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| % curl -s -c cookies.txt -b cookies.txt -I https://<your-project>.ddev.site:<https-port>/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HTTP/2 200 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 96 in docs/infrastructure_and_maintenance/clustering/clustering_with_ddev.md
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| server: Apache/2.4.65 (Debian) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vary: Origin,X-Editorial-Mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| via: 1.1 varnish (Varnish/7.1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-cache: HIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-cache-debug: 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-cache-hits: 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-cache-ttl: 87654.321 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-debug-token: 012345 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-debug-token-link: https://ddev-ibexa-tmp2.ddev.site:8443/_profiler/012345 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-powered-by: Ibexa Commerce v5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-robots-tag: noindex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-varnish: 12345 67890 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xkey: ez-all c52 ct42 l2 pl1 p1 p2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content-length: 45678 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You can see how the `web` server is responding to `varnish`: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```console | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| % curl -s -H "Surrogate-Capability: abc=ESI/1.0" http://127.0.0.1:<http-web-port>/product-catalog | grep 'esi:include' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <esi:include src="/_fragment?_hash=… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You can use `ddev varnishlog` command to monitor Varnish logs in real time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Due to how parameters are passed to the container, you may have to wrap some parameters in quotes twice, for example, the purge request monitoring: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ddev varnishlog -q "'ReqMethod ~ PURGE.*'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| For more information on topics such as available configurations, command lines, or monitoring, see [ddev/ddev-varnish README](https://github.com/ddev/ddev-varnish). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Fastly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| For Fastly (as for [[[= product_name_connect =]]](https://doc.ibexa.co/projects/connect/en/latest/)), the instance must be visible from Internet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| To use [ngrok](https://ngrok.com/) alongside [`ddev share`](https://docs.ddev.com/en/stable/users/topics/sharing/#using-ddev-share-easiest) is probably the easiest way to achieve this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Be careful when making a local development instance visible from Interne. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| For example, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - close ngrok tunnels when not needed anymore, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - don't communicate your ngrok URL to unintended people, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - don't use it for live demo on shared screen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - don't store it on a Fastly or [[= product_name_connect =]] account used by external people… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Install search engine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| A [search engine](search_engines.md) can be added to the cluster. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.