Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Varnish configuration to make Symfony routing behave #2857

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

Closed
wants to merge 6 commits into from
Closed
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
24 changes: 24 additions & 0 deletions cookbook/cache/varnish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,29 @@ that will invalidate the cache for a given resource:
}
}

Routing
------------------

To ensure that the 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
a different port (e.g. 8080).

Copy link
Member

Choose a reason for hiding this comment

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

you should wrap your lines after the first word that crosses the 72th character

.. code-block:: text

sub vcl_recv {
if (req.http.X-Forwarded-Proto == "https" ) {
set req.http.X-Forwarded-Port = "443";
} else {
set req.http.X-Forwarded-Port = "80"
}
}

.. note::

Remember to set ``framework.trust_proxy_headers: true`` in the Symfony
configuration for this to work.

.. _`Edge Architecture`: http://www.w3.org/TR/edge-arch
.. _`GZIP and Varnish`: https://www.varnish-cache.org/docs/3.0/phk/gzip.html