Create an NGINX virtual host

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 /opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf file and comment out the line below so that it looks like this:

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

    include "/opt/bitnami/apps/APPNAME/conf/nginx-vhosts.conf";
  • Update the application’s nginx-app.conf file at /opt/bitnami/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 /opt/bitnami/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 /opt/bitnami/ restart nginx
Last modification April 8, 2020