title: Symfony2 behind ELB is redirecting to http instead of https
body: <p><strong>Issue:</strong></p>
  
  <ul>
  <li>User logs in with <a href="https://example.com/login" rel="noreferrer">https://example.com/login</a></li>
  <li>Authentication is approved</li>
  <li>As configured in security.yml Symfony2 redirects user to profile page after login.</li>
  <li><strong>But it redirects them to the wrong url <a href="http://example.com/homepage" rel="noreferrer">http://example.com/homepage</a></strong></li>
  </ul>
  
  <p><strong>security.yml</strong>:</p>
  
  <pre><code>security:
  
      encoders:
          FOS\UserBundle\Model\UserInterface: 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
  </code></pre>
  
  <p><strong>Environment Architecture:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/FbLY1.png" alt="enter image description here"></p>
  
  <p>The Server1 and Server2 holds Symfony2 application. </p>
  
  <p><strong>Question:</strong></p>
  
  <p>How to force Symfony to generate redirect URL with https protocol instead http?</p>
  
  <p><strong>So far I have looked at these docs, and the solution didn't work work in my case:</strong></p>
  
  <ul>
  <li><a href="http://symfony.com/doc/current/cookbook/routing/scheme.html" rel="noreferrer">http://symfony.com/doc/current/cookbook/routing/scheme.html</a></li>
  </ul>