How to configure Nginx as a reverse proxy for Sapho Server running on Apache Tomcat

Audience: System administrators installing and configuring Sapho Server

This is Step-by-step guide for Ubuntu/Debian and CentOS based operating systems and these steps may vary slightly depending on your configuration and environment.

Step 1: Install Nginx

On Ubuntu/Debian

sudo apt-get install -y nginx

CentOS based distributions

sudo yum install -y nginx

Step 2: Configure Nginx

  1. Download https://github.com/saphoinc/config-templates/blob/master/nginx.conf to
    /etc/nginx/conf.d/tomcat.conf
  2. Open tomcat.conf and replace with proper values*:
    {{ nginx_server_name }}
    {{ nginx_ssl_cert_name }}
    {{ nginx_ssl_cert_key }}
  3. If you are installing Nginx on a server other than the one Sapho/Tomcat is on, then also update this directive as needed:
    proxy_pass http://127.0.0.1:8080/
  4. Restart Nginx:
    sudo service nginx restart

* for SSL Certificate Installation in Nginx see the how to by DigiCert.

If you would like to restrict access to the builder tool via source IP (in this example, CIDR 172.16.0.0/24), you can add the following (into the same Nginx config file you set up above):

location ~ ^/(admin) {
   allow 172.16.0.0/24;
   deny all;
}