diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-07 13:59:09 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-07 13:59:09 +0000 |
| commit | ea2af939642cd7cc780becdcad5e3ab9b478ef26 (patch) | |
| tree | f300d170619784ddbeb0cf88fdd3f7f7f6815eb7 /docs | |
| parent | f21ab7d46df904ece47ba59f1beba09515b59e58 (diff) | |
| download | genenetwork4-ea2af939642cd7cc780becdcad5e3ab9b478ef26.tar.gz | |
etc: the host is vesuvio.pu.ac.ke, not .ac.uk
The certificate on :443 carries subjectAltName DNS:vesuvio.pu.ac.ke, and vesuvio.pu.ac.uk does not resolve at all, so the config as committed could not have matched a request for the real name: nginx falls through to the default server, which is why /gn4/... answered 404 from nginx rather than a 502 from genenetwork4. * etc/nginx-vesuvio.pu.ac.uk.conf -> etc/nginx-vesuvio.pu.ac.ke.conf: server_name and the certificate paths. * docs/nginx.md: the same rename, and a "Checking it" section that starts from what actually gets in the way on the box -- TLS validates the URL hostname rather than a Host: header, so on-box checks need --resolve against the name on the certificate, and a mismatch there and in server_name look identical (default server answers).
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/nginx.md | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/docs/nginx.md b/docs/nginx.md index cf59152..61fc609 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -1,6 +1,6 @@ # Publishing genenetwork4 under a path prefix with nginx -How to put genenetwork4 on `https://vesuvio.pu.ac.uk/gn4/` while the +How to put genenetwork4 on `https://vesuvio.pu.ac.ke/gn4/` while the server itself listens on a loopback port, with no gn-auth: a bearer token minted from `scripts/gn-auth-stub.py` (see "Authentication" below). @@ -48,10 +48,10 @@ genenetwork4 server { listen 443 ssl; http2 on; - server_name vesuvio.pu.ac.uk; + server_name vesuvio.pu.ac.ke; - ssl_certificate /etc/nginx/ssl/vesuvio.pu.ac.uk.pem; - ssl_certificate_key /etc/nginx/ssl/vesuvio.pu.ac.uk.key; + ssl_certificate /etc/nginx/ssl/vesuvio.pu.ac.ke.pem; + ssl_certificate_key /etc/nginx/ssl/vesuvio.pu.ac.ke.key; # genenetwork4 is mounted at /gn4/. The trailing slash on proxy_pass # is what translates the prefix away: /gn4/species -> /species. @@ -110,8 +110,8 @@ server { } ``` -For the `vesuvio.pu.ac.uk/gn4` deployment as configured, -[`etc/nginx-vesuvio.pu.ac.uk.conf`](../etc/nginx-vesuvio.pu.ac.uk.conf) is +For the `vesuvio.pu.ac.ke/gn4` deployment as configured, +[`etc/nginx-vesuvio.pu.ac.ke.conf`](../etc/nginx-vesuvio.pu.ac.ke.conf) is the same thing as a complete, drop-in file -- TLS, log format, the `/gn4` redirect, and the `/compute/` and `/get-test-token` refusals. Note that it refuses `/compute/*`: those endpoints take server-side file paths, so @@ -133,12 +133,12 @@ with `/gn4/...` hrefs, and an error body comes back with Every success envelope carries `next: [{"href": ...}]`, and every error carries `spec_url`, `type` and sometimes `next`. All of them are root-relative by design -- genenetwork4 has no idea it is behind a -prefix -- so a client at `https://vesuvio.pu.ac.uk/gn4/species` is told -to call `https://vesuvio.pu.ac.uk/groups`. +prefix -- so a client at `https://vesuvio.pu.ac.ke/gn4/species` is told +to call `https://vesuvio.pu.ac.ke/groups`. Three ways to deal with that, in order of preference: -1. **Give the service its own host** (`https://gn4.pu.ac.uk/`) and drop +1. **Give the service its own host** (`https://gn4.example.org/`) and drop the prefix. Nothing needs rewriting, and this is what the rest of the README assumes. 2. **Rewrite the three keys in nginx**, as in the config above. It is @@ -167,7 +167,7 @@ Three ways to deal with that, in order of preference: `/openapi.json` itself is served fine through the proxy. Its `paths` are root-relative, which is correct OpenAPI: a tool that reads the document -from `https://vesuvio.pu.ac.uk/gn4/openapi.json` resolves them under +from `https://vesuvio.pu.ac.ke/gn4/openapi.json` resolves them under `/gn4` on its own. A tool that hard-codes `paths` against the host root will call the wrong place -- that is the same prefix problem, one level further out. @@ -211,16 +211,47 @@ docs/gn-auth.md. ## Checking it +From a client, plainly: + ``` -curl -s https://vesuvio.pu.ac.uk/gn4/version -curl -s https://vesuvio.pu.ac.uk/gn4/openapi.json | head -c 200 +curl -s https://vesuvio.pu.ac.ke/gn4/version +curl -s https://vesuvio.pu.ac.ke/gn4/openapi.json | head -c 200 TOKEN=$(cat /run/gn4/public.token) curl -s -H "Authorization: Bearer $TOKEN" \ - "https://vesuvio.pu.ac.uk/gn4/species" | head -c 200 + "https://vesuvio.pu.ac.ke/gn4/species" | head -c 200 curl -s -H "Authorization: Bearer $TOKEN" \ - "https://vesuvio.pu.ac.uk/gn4/groups/BXD/traits?limit=3" + "https://vesuvio.pu.ac.ke/gn4/groups/BXD/traits?limit=3" +``` + +On the box itself, two things trip up the obvious `curl -H "Host: ..." +https://localhost`: + +* TLS validates the **hostname in the URL**, not the `Host:` header, which + only arrives after the handshake -- so `https://localhost` fails against + a certificate for `vesuvio.pu.ac.ke` no matter what `Host:` says. Use + `--resolve` to connect to loopback while still verifying the real name. +* use the name that is actually on the certificate. Check it rather than + assuming (`openssl s_client -connect 127.0.0.1:443 -servername + vesuvio.pu.ac.ke </dev/null | openssl x509 -noout -text | grep -A1 + 'Subject Alternative Name'`); a mismatch here and a mismatch in + `server_name` are the same symptom -- the default server answers instead, + so `/` shows whatever else is configured on the host and `/gn4/...` is a + 404 from nginx rather than from genenetwork4. + +``` +R="--resolve vesuvio.pu.ac.ke:443:127.0.0.1" +curl -sSI $R https://vesuvio.pu.ac.ke/ | head -3 # 302 -> /gn4/ +curl -sSI $R https://vesuvio.pu.ac.ke/gn4 | head -3 # 301 -> /gn4/ +curl -s $R https://vesuvio.pu.ac.ke/gn4/version # the version envelope +curl -s $R -o /dev/null -w '%{http_code}\n' -X POST \ + https://vesuvio.pu.ac.ke/gn4/get-test-token # 404: not registered +curl -s $R -o /dev/null -w '%{http_code}\n' -X POST \ + https://vesuvio.pu.ac.ke/gn4/compute/correlation # 403: refused here ``` +A 502 instead means nginx is fine and genenetwork4 is not listening on +`GENENETWORK4_PORT`; check `curl -s http://127.0.0.1:3000/version` directly. + The `/version` reply also names the git revision and build date, which is the quickest way to confirm the proxy is talking to the process you think it is. @@ -229,7 +260,7 @@ To check the link rewriting, follow a `next` from a body: ``` curl -s -H "Authorization: Bearer $TOKEN" \ - https://vesuvio.pu.ac.uk/gn4/groups/BXD | grep -o '"href": "[^"]*"' | head -3 + https://vesuvio.pu.ac.ke/gn4/groups/BXD | grep -o '"href": "[^"]*"' | head -3 ``` Each one should start with `/gn4/`. Without the `sub_filter` lines they |
