sudo amazon-linux-extras install -y nginx1Configure SSL
Putting nginx in front
An app that binds to 127.0.0.1 (the pattern used by baseball-trajectory in Install Apps and daemonized in Lab 10) isn’t reachable from outside its own instance. Something has to accept the connection on 443, terminate TLS, and forward the request inward.
Install nginx:
Create the site configuration:
sudo vim /etc/nginx/conf.d/baseball-trajectory.confserver {
listen 443 ssl;
server_name trajectory.example.com;
ssl_certificate /etc/letsencrypt/live/trajectory.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/trajectory.example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}The certificate paths assume you have a hostname pointed at the instance, covered in Configure DNS.
Test the configuration before reloading, since a syntax error will otherwise take nginx down entirely:
sudo nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfulThen enable and start it, the same two step pattern as the app itself:
sudo systemctl enable --now nginxLoad the hostname in a browser and you should get the app’s landing page, served over HTTPS.