问题:
在与 https://example.com/login 用户登录 认证批准 中配置security.yml Symfony2中重定向用户登录后的个人资料页面。 但是它重定向他们错误的URL http://example.com/homepage User logs in with https://example.com/login Authentication is approved As configured in security.yml Symfony2 redirects user to profile page after login. But it redirects them to the wrong url http://example.com/homepagesecurity.yml
security:
encoders:
FOSUserBundleModelUserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
main:
pattern: ^/
form_login:
check_path: /login_check
login_path: /login
default_target_path: /profile
provider: fos_userbundle
logout:
path: /logout
target: /splash
anonymous: ~
access_control:
- { roles: ROLE_USER, requires_channel: https }
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
acl:
connection: default
环境体系结构:
在Server1和Server2持有Symfony2的应用程序。
The Server1 and Server2 holds Symfony2 application.
问:
如何强制Symfony的生成与HTTPS协议的重定向URL而不是http?
How to force Symfony to generate redirect URL with https protocol instead http?
到目前为止,我已经看过这些文档和解决方案并没有在我的情况下工作的工作:
http://symfony.com/doc/current/cookbook/routing/scheme.html看看
厂商/ symfony中/ symfony中/ src目录/ Symfony的/分量/ HttpFoundation / Request.php
vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Request.php
AWS ELB的使用HTTP_X_FORWARDED_PROTO和HTTP_X_FORWARDED_PORT而Symfony的看起来X_FORWARDED_PROTO和X_FORWARDED_PORT头以判断连接及其安全状态。
AWS ELB's use HTTP_X_FORWARDED_PROTO and HTTP_X_FORWARDED_PORT while Symfony looks the X_FORWARDED_PROTO and X_FORWARDED_PORT headers to judge the connection and its secure status.
您可以尝试更改这些密钥在trustedHeaders虽然我不建议直接更改它们,但寻找一种方法来覆盖这些。
You can try changing those keys in the trustedHeaders although I would not recommend directly changing them but finding a way to override those.
protected static $trustedHeaders = array(
self::HEADER_CLIENT_IP => 'X_FORWARDED_FOR',
self::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST',
self::HEADER_CLIENT_PROTO => 'HTTP_X_FORWARDED_PROTO',
self::HEADER_CLIENT_PORT => 'HTTP_X_FORWARDED_PORT',
);
参考 - http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html#x-forwarded-for
Reference - http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html#x-forwarded-for
上一篇:URL重写休息时的index.php URL =指数?(参数"指数")。为什么?指数、重写、参数、URL
下一篇:htaccess的密码保护功能允许127.0.0.1而不是localhost保护功能、而不是、密码、htaccess