Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Fix docs on trusted hosts#10138

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
fabpot wants to merge2 commits intosymfony:2.8fromfabpot:trusted-hosts-fix
Closed
Changes fromall 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
18 changes: 9 additions & 9 deletionsreference/configuration/framework.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -379,16 +379,16 @@ method might be vulnerable to some of these attacks because it depends on
the configuration of your web server. One simple solution to avoid these
attacks is to whitelist the hosts that your Symfony application can respond
to. That's the purpose of this ``trusted_hosts`` option. If the incoming
request's hostname doesn't match one in this list, the application won't
respond and the user will receive a500 response.
request's hostname doesn't match oneof the regular expressionsin this list,
the application won'trespond and the user will receive a400 response.

.. configuration-block::

.. code-block:: yaml

# app/config/config.yml
framework:
trusted_hosts: ['example.com', 'example.org']
trusted_hosts: ['^example\.com$', '^example\.org$']

.. code-block:: xml

Expand All@@ -402,8 +402,8 @@ respond and the user will receive a 500 response.
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:trusted-host>example.com</framework:trusted-host>
<framework:trusted-host>example.org</framework:trusted-host>
<framework:trusted-host>^example\.com$</framework:trusted-host>
<framework:trusted-host>^example\.org$</framework:trusted-host>
<!-- ... -->
</framework:config>
</container>
Expand All@@ -412,17 +412,17 @@ respond and the user will receive a 500 response.

// app/config/config.php
$container->loadFromExtension('framework', array(
'trusted_hosts' => array('example.com', 'example.org'),
'trusted_hosts' => array('^example\.com$', '^example\.org$'),
));

Hosts can also be configuredusing regular expressions (e.g. ``^(.+\.)?example.com$``),
which make it easier to respond to any subdomain.
Hosts can also be configuredto respond to any subdomain, via
``^(.+\.)?example\.com$`` for instance.

In addition, you can also set the trusted hosts in the front controller
using the ``Request::setTrustedHosts()`` method::

// web/app.php
Request::setTrustedHosts(array('^(.+\.)?example.com$', '^(.+\.)?example.org$'));
Request::setTrustedHosts(array('^(.+\.)?example\.com$', '^(.+\.)?example\.org$'));

The default value for this option is an empty array, meaning that the application
can respond to any given host.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp