Skip to main content

Lab 12: Computer Networks

Published

2026-12-02

WarningCaution

This chapter is under review. Thank you for your patience.

How does a request typed into a browser find the right program on a server? Every service on our instance listens on its own port, and the security group only lets port 22 through. This lab answers the chapter’s questions about URLs, ports, and proxies. The hands on part, putting RStudio Server and JupyterHub behind one nginx proxy on port 80, is in Accessibility.

Comprehension questions

“1. What are the four parts of a URL, and what does each one do?”

A URL has a protocol, a domain, a port, and a path. The protocol says what kind of traffic it is, and the domain says which server. The port picks a service on that server, and the path picks the resource it returns:

%%{init: {'theme': 'base', 'themeVariables': {'fontFamily': 'monospace', 'fontSize':'16px'}}}%%

block-beta
    columns 4
    P["https://"] D["example.com"] Po[":443"] Pa["/jupyter"]
    Pl["protocol<br/>what kind of traffic"] Dl["domain<br/>which server"] Pol["port<br/>which service"] Pal["path<br/>which resource"]

    style P fill:#2A6F77,stroke:#fff,color:#fff
    style D fill:#1B2A41,stroke:#fff,color:#fff
    style Po fill:#D2562B,stroke:#fff,color:#fff
    style Pa fill:#5B8C5A,stroke:#fff,color:#fff

The Four Parts of a URL

The port is usually hidden. Browsers fill in 80 for http:// and 443 for https://, so https://example.com/jupyter and https://example.com:443/jupyter are the same address. A port only shows up in the URL when the service listens somewhere else, like http://127.0.0.1:8000 for baseball-trajectory in Installing a Real Application.

The domain is a name for an IP address. DNS turns the name into the address, which is covered in Lab 13.

“2. When you configure a service on a server, how do you get it onto the right port?”

The service picks its port, not the operating system. Each one reads the port from its own configuration, so the fix is always to change that setting and restart the service:

Service Default port Where the port is set
RStudio Server 8787 www-port in /etc/rstudio/rserver.conf
JupyterHub 8000 c.JupyterHub.bind_url in jupyterhub_config.py
baseball-trajectory 8000 --port in the unit file’s ExecStart line
nginx 80 listen in a server block

The baseball-trajectory unit file from Lab 10 shows the pattern. The port (and the address it binds to) is an argument on the command that starts the app:

ExecStart=/opt/baseball-trajectory/.venv/bin/shiny run baseball_trajectory.app:app --host 127.0.0.1 --port 8000

Two services can’t share a port on the same address. JupyterHub and baseball-trajectory both default to 8000, so one of them has to move before both can run on our instance.

Once a service is listening, ss (the replacement for netstat on AL2023) confirms which port it holds:

sudo ss -tlnp

Getting a service onto the right port is only half the job. The security group still blocks every port except 22, so traffic from outside never reaches it. The usual answer is to open one port (80 or 443) for a proxy and let the proxy forward each path to the right internal port.

“3. Draw a mind map of accessing a resource in a browser. Include URL, domain, IP address, port, path, 80, 443, 8000, proxy, server, HTTP, HTTPS, status code, and protocol.”

The mind map groups the terms under the part of the URL they belong to, plus the server side that answers the request:

%%{init: {'theme': 'base', 'themeVariables': {'fontFamily': 'monospace', 'fontSize':'13px'}}}%%

mindmap
  root((URL))
    Protocol
      HTTP
        80
      HTTPS
        443
    Domain
      IP address
    Port
      80
      443
      8000
    Path
    Server
      Proxy
        Forwards path to port
      Status code
        200 OK

Accessing a Resource Mind Map

“a. A Shiny app at http://my-shiny.com, with Shiny Server on port 80.”

The URL has no port, so the browser uses 80 for http://. Shiny Server listens on 80 itself, so no proxy is needed. The path is /, and Shiny Server returns the app with a 200 status code:

%%{init: {'theme': 'base', 'themeVariables': {'fontFamily': 'monospace', 'fontSize':'13px'}}}%%

sequenceDiagram
    participant B as Browser
    participant DNS
    participant S as Shiny Server :80
    B->>DNS: my-shiny.com?
    DNS-->>B: IP address
    B->>S: HTTP GET / (port 80)
    S-->>B: 200 OK, the app

Shiny Server on Port 80

The security group needs 80 open for this to work, and the traffic isn’t encrypted.

“b. JupyterHub at https://example.com/jupyter, with JupyterHub on port 8000.”

The browser uses 443 for https://, but JupyterHub listens on 8000. A proxy closes the gap. It listens on 443, handles the TLS encryption, and forwards anything under /jupyter to 8000. JupyterHub also has to know it lives at /jupyter, or the links it writes into its pages point at / and break:

%%{init: {'theme': 'base', 'themeVariables': {'fontFamily': 'monospace', 'fontSize':'13px'}}}%%

sequenceDiagram
    participant B as Browser
    participant DNS
    participant N as nginx :443
    participant J as JupyterHub :8000
    B->>DNS: example.com?
    DNS-->>B: IP address
    B->>N: HTTPS GET /jupyter (port 443)
    N->>J: HTTP GET /jupyter (port 8000)
    J-->>N: 200 OK
    N-->>B: 200 OK, encrypted

JupyterHub Behind a Proxy

Only 443 is open in the security group. Port 8000 stays closed, so JupyterHub is reachable only through the proxy. Accessibility builds the port 80 version of this setup, and Configure SSL adds 443.

Recap

  1. A URL names a protocol, a domain, a port, and a path. Browsers fill in 80 or 443 when the port is missing.

  2. Each service reads its port from its own configuration, and no two services can hold the same port. sudo ss -tlnp shows which service holds which port.

  3. The security group decides which ports outside traffic can reach. A proxy lets one open port serve several services, each on its own path.