A path under the hostname
This page puts api behind the front door at a path: /api on guestbook’s
hostname goes to api, and everything else stays with web. One hostname
means one certificate and one name for a browser to remember, and the page
can call its API without crossing to another host.
x-shc-path on a service serves it at that path under the primary’s
hostname. An app has one front door, so a path always hangs under it.
services: web: image: nginx:1.27-alpine expose: - "80" volumes: - ./site:/usr/share/nginx/html:ro x-shc-primary: true api: image: traefik/whoami:v1.10 command: ["--port", "8080", "--name", "guestbook-api"] expose: - "8080" x-shc-path: /api$ shc update guestbook...$ curl -sk --resolve guestbook.learn.test:443:127.0.0.1 https://guestbook.learn.test/api/helloName: guestbook-api...GET /api/hello HTTP/1.1...api answered, and it received the whole path, /api/hello. An API written
to live at / has no route for that. x-shc-path-strip: true takes the
prefix off before the request reaches the service.
services: web: image: nginx:1.27-alpine expose: - "80" volumes: - ./site:/usr/share/nginx/html:ro x-shc-primary: true api: image: traefik/whoami:v1.10 command: ["--port", "8080", "--name", "guestbook-api"] expose: - "8080" x-shc-path: /api x-shc-path-strip: true$ shc update guestbook...$ curl -sk --resolve guestbook.learn.test:443:127.0.0.1 https://guestbook.learn.test/api/helloName: guestbook-api...GET /hello HTTP/1.1...$ curl -sk --resolve guestbook.learn.test:443:127.0.0.1 https://guestbook.learn.test/<!doctype html><title>guestbook</title><p>Sign the guestbook.</p>api now sees /hello, and the bare hostname still opens the page.
Next: A volume.
shc@docs:~$