Set Up BuildWise Server Behind Nginx with HTTPS

How to get your CT server running on Nginx

Courtney Zhan
4 min readOct 26, 2024

BuildWise CT server is super-easy to set up, and I’ve documented how in previous articles. In this article, I will briefly recap how to install BuildWise and then walk through how to set it up behind Nginx a popular web server with HTTPS.

A Quick Recap of BuildWise Installation

Prerequisite

Ruby 3.2 (not v3.3 yet). On macOS, I recommend using rbenv to manage your Ruby distribution.

If you have already activated using Ruby 3.3 on your computer, run the below to force Ruby 3.2 for the current project.
% cd ~/agileway/buildwise-2.5.6
% rbenv local 3.2.5

Run in demo mode

Download BuildWise server (in .zip file, 1.4MB), unzip to a folder.

  1. Install the required libraries (called gems in Ruby)
    run cd buildwise-2.5.6; bundle command in a terminal window.
  2. Start it up (use the sh file for macOS or Linux, and the bat file for Windows)
    ./bundle-start-demo.sh
  3. Open BuildWise server in a browser window

Success! Off you go.

Run in production mode

No change to the app, just need to get a MySQL database server ready.

1. Create buildwise_production database and update the database credentials in config/database.yml.

2. Edit bundle-start.sh to change the running port to 80 (from 3618).

3. Start the BuildWise server in production mode.

./bundle-startup.sh

Make BuildWise Available for Team Use

So far, you can do Continuous Testing locally. When you are ready to share your achievement with the team, do the following.

  1. Find out your machine’s IP address

2. Visit by IP address.

Then share that with your colleagues.

Some might find IP addresses hard to remember. A quick solution is to add one entry into /etc/hosts for every computer that wishes to access it.

Then, instead of visiting the IP address, use build.server.

Please note: 192.168.20.X is an internal IP address, only accessible with the local network.

Given the CT server’s role in executing automated end-to-end tests for app development, this setup is sufficient for meeting 99% of needs.

Advanced: Auto-Startup, HTTPS, Load Balancing, …

The answer to all the above is simple: Run BuildWise server within a web server, e.g. Nginx or Apache.

My preference is Nginx.

“Nginx is used by 33.9% of all the websites whose web server we know.” — w3techs.com

So, if the BuildWise server is running with Nginx, it meets any infrastructure setup requirements. The good news is that it is very easy to set up.

Here, I just focus on BuildWise server configuration in Nginx. By the way, Nginx installation is easy. The reason: BuildWise is developed based on Sinatra, which can run with Phusion Passenger. Use the following guide to set up Passenger:

If Nginx is installed via brew, the configuration folder is /opt/homebrew/etc/nginx. Site definitions are stored under:

/opt/homebrew/etc/nginx/sites-enabled

BuildWise CT server is considered a website in Nginx. For this example, I named it ct.agileway.net.

Create a file, such asbuildwise-server with the below content.

server {
listen 80;
server_name ct.agileway.net;
root /opt/www/sinatra/buildwise/public;
passenger_enabled on;
passenger_min_instances 2;
rails_env production;

# optimzation to server static files using Nginx
location ~* \.(jpg|jpeg|png|gif|ico)$ {
gzip_static on;
expires 9M;
access_log off;
log_not_found off;
}

}

The key info is the root, where your BuildWise CT server is. For example, if you download BuildWise 2.5.6 to /usr/local/buildwise-2.5.6, then the value for root is /usr/local/buildwise-2.5.6/public.

Restart Nginx.

I used Firefox browser this time, to highlight the non secure.

With Nginx, we accomplished at least two:

  • Auto start-up
  • Speed performance by serving static files by Nginx

There is one more optional thing to do: set up HTTPS. To enable that, you first need to get an SSL certificate.

Then, add another server config file under /opt/homebrew/etc/nginx/sites-enabled.

server {
listen 443 ssl;
server_name ct.agileway.net;
client_max_body_size 20M;

ssl_certificate /path/my/certificate.crt;
ssl_certificate_key /path/my/certificate.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

root /opt/www/sinatra/buildwise/public;
passenger_enabled on;
passenger_min_instances 1;
rails_env production;

}

After this, your BuildWise server is successfully running on Nginx!

--

--

No responses yet