🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Web & Software Development › Capstone Project: Full-Stack Web Application Build, Documentation, and Defense › Lesson 3
TEC-WEB46-08 · Lesson 3 · 56 clock hours · lab

Frontend Integration, Linux Deployment, and Security Hardening

Objective. The student will integrate a responsive HTML/CSS/JavaScript frontend with the backend API, deploy the complete application to a Linux server (virtual machine or cloud instance) using a shell script and a process manager, configure UFW firewall rules and HTTPS, and verify the live deployment passes a functional and security checklist — mapping to CompTIA Linux+ exam areas: file permissions, service management, firewall configuration, and shell scripting.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Frontend Integration, Linux Deployment, and Security Hardening

This lab brings your capstone project to life on a real Linux server. You will wire your HTML/CSS/JavaScript frontend to your backend API, deploy the combined application to Ubuntu Server 22.04 LTS, lock down the server with a firewall and HTTPS, and verify that everything works correctly. Each step maps directly to CompTIA Linux+ exam areas: file permissions, service management, firewall configuration, and shell scripting.

Connecting the Frontend to the Backend API

Your frontend makes HTTP requests to API endpoints served by your backend (Python/Gunicorn or PHP-FPM). Before deployment, confirm three things in your JavaScript code:

1. Base URL — Use a relative path (`/api/...`) or an environment variable so the same code works locally and on the server without hard-coded IP addresses.

2. CORS headers — Your backend must send `Access-Control-Allow-Origin` headers that match the production domain, not a wildcard, unless the resource is genuinely public.

3. Error handling — Every `fetch()` call should have a `.catch()` block that displays a user-friendly message instead of a silent failure.

Commit and push a clean build to the `main` branch before you begin the server work. The deployment script will pull from that branch.

Writing deploy.sh

A deployment script automates the steps a human could forget or perform out of order. Start every Bash script with a shebang (`#!/usr/bin/env bash`) so the OS knows which interpreter to use. Immediately follow it with `set -e`, which tells Bash to exit the moment any command returns a non-zero exit code. Without `set -e`, a failed `git pull` could leave the server running stale code while the script continues happily.

The script should:

File permissions matter here. Set the script to `chmod 750` so only the owner can execute it and group members can read it, but others have no access at all. Never leave a deployment script world-readable; it may contain paths, service names, or environment references that an attacker could exploit.

Configuring UFW and Obtaining TLS

UFW (Uncomplicated Firewall) is the standard tool on Ubuntu for managing `iptables` rules through a simpler interface. The principle of least privilege applies: allow only the ports your application needs.

```

sudo ufw default deny incoming

sudo ufw default allow outgoing

sudo ufw allow 22/tcp # SSH

sudo ufw allow 80/tcp # HTTP

sudo ufw allow 443/tcp # HTTPS

sudo ufw enable

```

Run `sudo ufw status verbose` to confirm the rules are active. Never disable port 22 before you have verified your SSH session still works — doing so locks you out of the server entirely.

For TLS, Certbot automates certificate issuance from Let's Encrypt. In lab environments without a registered domain, generate a self-signed certificate using `openssl`. Either way, configure Nginx to redirect all port-80 traffic to port 443 with a `301` redirect in the server block. Verify the redirect with:

```

curl -I http://yourdomain.com

```

You should see `HTTP/1.1 301 Moved Permanently` and a `Location:` header pointing to the HTTPS version. If you see `200 OK` over plain HTTP, the redirect is not working — correct the Nginx configuration and reload the service with `sudo systemctl reload nginx`.

Service Management with systemd

Systemd controls how your application starts, stops, and restarts. A unit file (stored in `/etc/systemd/system/`) defines the service. Key fields include `ExecStart`, `Restart=on-failure`, `User`, and `WorkingDirectory`. Run `sudo systemctl daemon-reload` whenever you edit the unit file, then `sudo systemctl enable yourapp` to start it automatically at boot.

Check the service status and recent logs with:

```

sudo systemctl status yourapp

sudo journalctl -u yourapp -n 50

```

Security Hardening and the OWASP Checklist

After the application is live, walk through a manual OWASP checklist. At minimum, verify:

Document every finding — passed checks and any issues you remediated — in a one-page security hardening report saved as `/docs/security-hardening-report.md` and committed to the repository.

Functional Test Checklist

Before calling the deployment complete, test every CRUD operation (Create, Read, Update, Delete), log in and log out, attempt an action while unauthenticated to confirm access control, and load a non-existent URL to confirm the 404 page. Record each result in the instructor's deployment checklist. All critical items must show Pass before sign-off.

Safety Note

When working on a remote server, always maintain at least one active SSH session while making firewall or service changes. Test new rules in a second terminal before closing the first. A misconfigured firewall rule or a failed service restart can make the server unreachable; having a second session open gives you a chance to roll back without requesting a server reset.

Key terms9

ShebangThe first line of a shell script (e.g., #!/usr/bin/env bash) that tells the operating system which interpreter to use when executing the file.
set -eA Bash option that causes the script to exit immediately if any command returns a non-zero (failure) exit code, preventing subsequent steps from running on a broken state.
UFW (Uncomplicated Firewall)A front-end to Linux iptables included with Ubuntu that provides a simpler command-line interface for managing incoming and outgoing network traffic rules.
systemd unit fileA configuration file stored in /etc/systemd/system/ that defines how the system starts, stops, monitors, and restarts a service or application process.
TLS (Transport Layer Security)A cryptographic protocol that encrypts data in transit between a client and a server; websites use it to serve content over HTTPS on port 443.
CertbotAn open-source tool from the Electronic Frontier Foundation that automates requesting, installing, and renewing TLS certificates from the Let's Encrypt certificate authority.
OWASP (Open Web Application Security Project)A nonprofit foundation that publishes widely used guidance and checklists for identifying and remediating common web application security vulnerabilities.
chmod 750A Linux file permission setting giving the owner read, write, and execute access; the group read and execute access; and no access to all other users.
Reverse proxyA server (such as Nginx) that sits in front of an application server (such as Gunicorn), forwards client requests to it, and returns the response — handling TLS termination and static files efficiently.
In class: Write a Bash deployment script (deploy.sh) that pulls the latest code from the main branch, installs dependencies, runs database migrations, restarts the application process (systemd service or Gunicorn/Nginx), and logs the result to /var/log/deploy.log with a timestamp — instructor reviews the script for correct shebang, set -e error handling, and restricted file permissions (chmod 750). · Configure UFW to allow only ports 22, 80, and 443; obtain and install a TLS certificate using Certbot (Let's Encrypt) or a self-signed certificate for lab environments; verify HTTPS redirect is enforced using curl -I and correct any misconfiguration before sign-off. · Run the completed live application through a functional test checklist (all CRUD operations, authentication, and error pages) and a manual OWASP checklist; document every finding in a one-page security hardening report and commit it to the repository under /docs.
Materials: Ubuntu Server 22.04 LTS (VM via VirtualBox or a cloud provider free tier), Nginx, Gunicorn or PHP-FPM, systemd, UFW, Certbot (Let's Encrypt), Bash scripting reference (GNU Bash manual), CompTIA Linux+ objectives guide, instructor deployment checklist, VS Code Remote-SSH extension
Check: Instructor visits the live URL and runs the functional and security checklists; deployment earns a pass when all critical checklist items are marked Pass, the site loads over HTTPS, and the deploy.sh script runs without error on a clean server — any critical failure requires remediation and re-check within two class days.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

CompTIA Linux+ — Shell scripting and automation
1. A student's deploy.sh script runs git pull successfully but then silently continues even though pip install fails. Which addition to the script would have prevented this behavior?
CompTIA Linux+ — Firewall configuration
2. After configuring UFW on the capstone server, the student runs 'sudo ufw status verbose' and sees that port 3306 (MySQL) is open to the world. Which action best follows the principle of least privilege?
CompTIA Linux+ — File permissions
3. A student sets a deployment script to chmod 777. Why would an instructor flag this as a security problem?
CompTIA Linux+ — Service management / Nginx configuration
4. The student runs 'curl -I http://example.com' and receives 'HTTP/1.1 200 OK'. What does this result indicate about the Nginx configuration?
CompTIA Linux+ — Service management
5. Which systemd command should the student run after editing a unit file at /etc/systemd/system/myapp.service?
CompTIA Linux+ — File permissions
6. A student's .env file containing database credentials is set to chmod 644. What is the security risk, and what permission should replace it?
OWASP / Security hardening
7. Which OWASP concern does the student address by adding the HTTP response header 'X-Content-Type-Options: nosniff'?
CompTIA Linux+ — Firewall configuration / Safety practices
8. Why should the student keep an existing SSH session open while enabling UFW or changing firewall rules?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.