Create an NGINX virtual host

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.

NGINX lets you configure virtual hosts for your applications, such that you can access them at (for example) instead of

NOTE: Replace APPNAME in the instructions below with the actual name/path to your application.

  • Edit the installdir/nginx/conf/bitnami/bitnami-apps-prefix.conf file and comment out the line below so that it looks like this:

    #include "installdir/apps/APPNAME/conf/nginx-prefix.conf";
  • Include the virtual host configuration file for your application in the installdir/nginx/conf/bitnami/bitnami-apps-vhosts.conf file:

    include "installdir/apps/APPNAME/conf/nginx-vhosts.conf";
  • Update the application’s nginx-app.conf file at installdir/apps/APPNAME/conf/nginx-app.conf with the revised application URL if necessary. For example, you might replace the line

    rewrite ^/wordpress/(.+)$ /wordpress/index.php?q=$1 last;


    rewrite ^/(.+)$ /index.php?q=$1 last;
  • Update the application configuration to reflect the revised URL if necessary. This is an application-specific step and different applications will require different changes. For example, if you are using WordPress, you would need to edit the installdir/apps/wordpress/htdocs/wp-config.php file and add the following lines:

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');
  • Restart the NGINX server:

    $ sudo installdir/ restart nginx
Last modification September 9, 2019