legacy-knowledge-base
公開されました Jun. 30, 2025

How to redirect from HTTP to HTTPS domain

written-by

Kartik Singh

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text
Note: please note that Liferay has renamed its Liferay Experience Could offerings to Liferay SaaS (formerly LXC) and Liferay PaaS (formerly LXC-SM).

Issue

  • When user hits the 'http://example.com' it should be redirected to the 'https://example.com' URL.

Environment

  • Liferay PaaS

Resolution

  • By default, the Nginx service uses the below snippet in the 'Nginx configuration' file which automatically redirects the domain from HTTP to HTTPS.

    if ($http_x_forwarded_proto = "http") {
     return 301 https://$host$request_uri;
     }

    For example:

    server {
            listen 80;
            server_name  example.com;
            
            if ($http_x_forwarded_proto = "http") {
            return 301 https://$host$request_uri;
        }
        }
    server {
            listen 80;
            server_name  www.example.com;
    
            if ($http_x_forwarded_proto = "http") {
            return 301 https://$host$request_uri;
        }
        }

Additional Information

  • URL Redirects
    • Ensure that HTTP-to-HTTPS redirects first direct to a secure version of the same original site, to prevent man-in-the-middle redirects to malicious sites. Ensure that redirects never point to HTTP addresses. The configure URL redirects via your environment’s Nginx configuration file.
  • Web Server Service (Nginx)
    • For PaaS environments, files in /webserver/configs/[ENV]/ are copied as overrides into /etc/nginx/ in the web server container in Liferay Cloud. Files in /webserver/configs/[ENV]/public/ are copied as overrides into var/www/html/.

    • And, as of web server version 6.0.0+, the nginx.conf file does not allow configurations that require root user permissions. Reference: Changes to the Web Server Service

did-this-article-resolve-your-issue

legacy-knowledge-base