@@ -176,14 +176,20 @@ that will invalidate the cache for a given resource:
176
176
}
177
177
}
178
178
179
- Routing
180
- ------------------
179
+ Routing and X-FORWARDED Headers
180
+ -------------------------------
181
181
182
182
To ensure that the Symfony Router generates urls correctly with Varnish,
183
- proper ```X-Forwarded` `` headers must be added. Headers depend on how you
184
- have configured hosts and ports for the web server and Varnish but this
185
- example should work if the web server is using the same IP as Varnish but
186
- a different port (e.g. 8080).
183
+ proper ```X-Forwarded` `` headers must be added so that Symfony is aware of
184
+ the original port number of the request. Exactly how this is done depends
185
+ on your setup. As a simple example, Varnish and your web server are on the
186
+ same machine and that Varnish is listening on one port (e.g. 80) and Apache
187
+ on another (e.g. 8080). In this situation, Varnish should add the ``X-Forwarded-Port ``
188
+ header so that the Symfony application knows that the original port number
189
+ is 80 and not 8080.
190
+
191
+ If this header weren't set properly, Symfony may append ``8080 `` when generating
192
+ absolute URLs:
187
193
188
194
.. code-block :: text
189
195
@@ -197,8 +203,9 @@ a different port (e.g. 8080).
197
203
198
204
.. note ::
199
205
200
- Remember to set ``framework.trust_proxy_headers: true `` in the Symfony
201
- configuration for this to work.
206
+ Remember to configure :ref: `framework.trusted_proxies<reference-framework-trusted-proxies> `
207
+ in the Symfony configuration so that Varnish is seen as a trusted proxy
208
+ and the ``X-Forwarded- `` headers are used.
202
209
203
210
.. _`Edge Architecture` : http://www.w3.org/TR/edge-arch
204
211
.. _`GZIP and Varnish` : https://www.varnish-cache.org/docs/3.0/phk/gzip.html
0 commit comments