Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c096852

Browse filesBrowse files
TomiSweaverryan
authored andcommitted
Varnish configuration to ensure routing works
1 parent c471fc7 commit c096852
Copy full SHA for c096852

File tree

Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed

‎cookbook/cache/varnish.rst

Copy file name to clipboardExpand all lines: cookbook/cache/varnish.rst
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,23 @@ that will invalidate the cache for a given resource:
176176
}
177177
}
178178
179+
Routing
180+
------------------
181+
To ensure Symfony Router generates urls correctly with Varnish, proper ```X-Forwarded``` headers must be added. Headers depend on how you have configured hosts and ports for the web server and Varnish but this example should work if the web server is using the same IP as Varnish but different port (e.g. 8080).
182+
183+
.. code-block:: text
184+
185+
sub vcl_recv {
186+
if (req.http.X-Forwarded-Proto == "https" ) {
187+
set req.http.X-Forwarded-Port = "443";
188+
} else {
189+
set req.http.X-Forwarded-Port = "80";
190+
}
191+
}
192+
193+
.. note::
194+
195+
Remember to set framework.trust_proxy_headers: true for this to work.
196+
179197
.. _`Edge Architecture`: http://www.w3.org/TR/edge-arch
180198
.. _`GZIP and Varnish`: https://www.varnish-cache.org/docs/3.0/phk/gzip.html

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.