Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-45199

Can't configure server host, protocol and port in a dynamic way

    Details

    • Type: Story
    • Status: Closed
    • Resolution: Inactive
    • Affects Version/s: 6.1.2 CE GA3, 6.1.30 EE GA3, 6.1.X EE, 6.2.10 EE GA1, 6.2.X EE
    • Fix Version/s: Master
    • Component/s: Util
    • Labels:
      None

      Description

      Right now, it isn't possible to configure Liferay for creating URL in a dynamic way using a load balancer/proxy.

      The only chance is having a "fixed" port and protocol using web.server.host and web.server.protocol properties. But this solution won't work if we want to have SSL offloading (so all the request to Liferay will go in http) and we want to access proxy using non-ssl protocol.

      To improve this, we can implement a solution that is app-server agnostic and can be applied to many web servers/proxies (as Apache, haproxy, nginx, etc). We can use custom http headers so Liferay can read through them the data needed to create the URL.

      Steps to reproduce:

      1. Install any web server proxy that can be configured to add custom HTTP headers (haproxy or Apache for example). Configure this proxy to startup on port 80 and to add a custom http header with name "X-Forwarded-Host". You can add the domain you want as the header value.
        Haproxy configuration example:
        frontend http_frontend
           bind *:80
          mode http
          option httpclose 
           reqadd X-Forwarded-Host:\ domain.com
           default_backend web_server
        
        backend web_server
          mode http
          balance roundrobin
          option httpclose
          option httpchk HEAD / HTTP/1.0
          cookie  JSESSIONID prefix
          server  app1_1 127.0.0.1:8080 cookie A check
        
      2. Edit /etc/hosts file and add a custom domain name for localhost you added in previous step:
        127.0.0.1	domain.com
        
      3. Enable custom http headers for URL in portal-ext.properties:
        web.server.forwarded.host.enabled=true
        
      4. Startup Liferay and web server proxy.
      5. Access http://localhost
      6. Examine HTML markup

      Expected behavior: URL in <head> section are starting with "domain.com".
      Actual behavior: URL in <head> section are starting with "localhost".

        Attachments

          Activity

            People

            Assignee:
            support-qa Support QA
            Reporter:
            juan.gonzalez Juan Gonzalez (Inactive)
            Recent user:
            Marta Elicegui
            Participants of an Issue:
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                Master