nativeInstallerdreamfactory

Force HTTPS redirection with NGINX

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

NOTE: The Approach A sections referred to below do not apply to Bitnami native installers. Users of Bitnami native installers should refer only to the Approach B sections.

Approach A: Bitnami installations using system packages

  • Modify the installdir/nginx/conf/server_blocks/APPNAME-server-block.conf file so that it looks like the example below. In the path above and the code example below, APPNAME is a placeholder which corresponds to the Bitnami application name. Replace this placeholder with the correct filename or path corresponding to the Bitnami application.

      server {
          listen 80 default_server;
          root installdir/APPNAME;
          return 301 https://$host$request_uri;
      }
    
  • Modify the server section of the installdir/nginx/conf/nginx.conf file so that it looks like this:

      server {
            listen 80;
            server_name localhost;
            return 301 https://$host$request_uri;
        }
    
  • After modifying the NGINX configuration file, open port 443 in the server firewall.

  • Restart NGINX to apply the changes.

Approach B: Self-contained Bitnami installations

  • Modify the server section of the installdir/nginx/conf/nginx.conf file so that it looks like this:

    server {
          listen 80;
          server_name localhost;
          return 301 https://$host$request_uri;
      }
    
  • After modifying the NGINX configuration file, open port 443 in the server firewall.

  • Restart NGINX to apply the changes.

Last modification August 13, 2021