SSL and SyncServer
When I started using SyncServer on AWS, I just directly incorporated SSL using letsencrypt into the Swift Kitura-based server.
This was following IBM's advice.
However, a few issues have led me away from that:
- It was necessary to run SyncServer as root.
Standard use of https and SSL uses port 443, which needs root access. Running programs as root is not a generally accepted security practice.
- How do you run a dev or staging instance of the server?
With an instance of SyncServer using port 443, this disallows other server instances from using port 443. Since SyncServer uses credentials from live accounts (e.g., Google or Facebook), we *always* want to be using SSL even when running dev or staging instances of the server.
- I wanted to experiment to try to solve a bug
More specifically, the issue could possibly be due to SSL problems.
- SSL might be handled more securely in other ways.
Until I started looking into this, I didn't realize that server configurations can play a role in SSL-related security. See for example.
I am going to leave this direct use of SSL available as a SyncServer configuration option but this doesn't seem the advisable way to use SSL.
Instead, I'm now using NGINX to proxy requests into the SyncServer.
HTTPS requests come into NGINX, and are proxied to SyncServer as HTTP requests.
To get NGINX running on Ubuntu 16.04 on AWS, I did the following:
- I installed NGINX
sudo apt-get update
sudo apt-get install nginx
- I checked to see if NGINX was running
The installation as above should start NGINX.
systemctl status nginx
- I modified the NGINX configuration at: /etc/nginx/sites-available/default
You need to be signed in as `root` to edit this file.
I read around on various references before making my changes (see references below).
The bulk of my configuration came from this.
I'm going to put this configuration in the file
nginx.conf
at the root of the SyncServer repo.
- Check the syntax of your config changes:
sudo nginx -t
- Reload your conf changes:
sudo systemctl reload nginx