---
# System prepended metadata

title: BBB Proxy Deployment
tags: [Bigbluebutton, ' proxy']

---

---
tags: Bigbluebutton, proxy
title: BBB Proxy Deployment
---

## BBB Proxy Deployment
This document shows different steps to deploy the big blue button proxy server
## Requirements
- Ubuntu 16.04 64-bit OS
- A domain name with a wildcard subdomain

### Clone the project
Go to the home directory to clone it from there 

```bash
cd /opt
```
Next, clone the project inside the home directory
```bash
git clone https://bitbucket.org/tm_ghenzinger/bbb-tm-proxy.git 
```
Next, navigate inside the project 
```bash
cd bbb-tm-proxy
```

## Install dependencies

Install os dependencies required to run the project. the script file `dependency-installer.sh` will take care of installing all the required dependencies.

Set permission for the file
```bash
sudo chmod +x dependency-installer.sh
```
Execute the script
```bash
sudo ./dependency-installer.sh
```

### Database Setup
Setting up your production database is pretty easy. Make sure to keep in mind that you should use a different password for your production databases.
#### Configuring PostgreSQL
We need to setup our postgres user (also named "deploy" but different from our linux user named "deploy") and database:
```bash
sudo su - postgres
```
Create a postgres user
```bash
createuser --pwprompt deploy
```
Create a database for the project and give the new user access to it.
```bash  
createdb -O deploy bbb_proxy_production # change "bbb_proxy" to your app's name which we'll also use later on
exit
```
The password you type in here will be the one to put in your `bbb_proxy/config/application.yml` later when you deploy your app for the first time.

## Install the application

### Adjust folder permissions 
```bash
sudo chown -R "$USER":www-data /opt/bbb-tm-proxy/
sudo chmod -R 0755 /opt/bbb-tm-proxy/
```

### Install the project's dependencies
```bash
bundler install
```

### Setup environment variables
Setting up the environment varibles inside the `application.yml` file

```bash
nano /opt/bbb-tm-proxy/config/application.yml
```
Add the environment details

```yaml=
SECRET_KEY_BASE: "1234567890"

RDS_DB_NAME: "bbb_proxy_production"
RDS_USERNAME: "deploy"
RDS_PASSWORD: "--user_secret--"
RDS_PORT: "5432"
```
Note: replace `--user_secret__` with the password of your postgres user.
Feel free to change the above environment variables to reflect the ones available in your machine

### Create the env file
Create a new env file for the configuration

```bash
nano /opt/bbb-tm-proxy/.env
```
Add the configuration for an admin user

```bash
ADMIN_USER_EMAIL="email@example.com"
ADMIN_USER_PASSWORD="sercret_password"
```
### Compile assets
```bash
bundle exec rake assets:precompile RAILS_ENV=production
```

### Migrate database
```bash
rake db:migrate RAILS_ENV=production
```

### Seed the database with the admin user
This creates the admin user using the details provided within the `.env` file
```bash
rake db:seed RAILS_ENV=production
```

## Adding The Nginx Host
In order to get Nginx to respond with the Rails app, we need to modify it's sites-enabled.

Open up `/etc/nginx/sites-enabled/default` in your text editor and we will replace the file's contents with the following:

```bash=
server {
            listen 80;
            listen [::]:80 ipv6only=on;
            
            server_name _;
            
            passenger_enabled on;
            rails_env    production;
            root         /opt/bbb-tm-proxy/public;
            # Add index.php to the list if you are using PHP
            index index.html index.htm index.nginx-debian.html;

            # redirect server error pages to the static page /50x.html
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
}
```

This is our Nginx configuration for a server listening on port 80. You need to change the `server_name` values to match the domain you want to use and in `root` replace `/opt/bbb-tm-proxy/public` with a path to the project

### Passenger

Next, we need to update the Nginx configuration to point Passenger to the version of Ruby that we're using. You'll want to open up `/etc/nginx/nginx.conf` in your favorite editor. I like to use `nano`, so I'd run this command:

```bash
sudo nano /etc/nginx/nginx.conf

    # You could also use vim if you don't like nano
    # sudo vim /etc/nginx/nginx.conf
```
Find the following lines, and uncomment them:
```bash=
    ##
    # Phusion Passenger
    ##
    # Uncomment it if you installed ruby-passenger or ruby-passenger-enterprise
    ##

    include /etc/nginx/passenger.conf;
```
Save and close nginx.conf. Then open `/etc/nginx/passenger.conf` in your editor to modify the ruby line:

```bash
sudo nano /etc/nginx/passenger.conf
```
And change the passenger_ruby line to point to your ruby executable:
```bash=
passenger_ruby /usr/local/bin/ruby;
```
The passenger_ruby is the important line here. Make sure you only set this once and use the line from the example that pertains to the version of Ruby you installed.

Once you've changed passenger_ruby to use the right version Ruby, you can run the following command to restart Nginx with the new Passenger configuration.

```bash
sudo service nginx restart
```