Реализовать лабораторную 4 на оценку 5

Добавить приватное S3-хранилище, вложения, presigned upload, reconciler и доказательства.
This commit is contained in:
Чиняева
2026-11-07 01:37:21 +03:00
parent ec540a1a72
commit f39ae06ef3
69 changed files with 5254 additions and 31 deletions
+57
View File
@@ -0,0 +1,57 @@
# Public entry point for laboratory 4.
#
# Docker's embedded DNS (127.0.0.11) returns every API replica IP for the
# Compose service name "api". The shared upstream zone + "resolve" picks up
# scale-up/scale-down and replacement containers without a reload. Passive
# checks remove a replica after failed connections; proxy_next_upstream lets a
# safe retry reach another backend.
worker_processes auto;
events {
worker_connections 4096;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
access_log /dev/stdout;
error_log /dev/stderr warn;
resolver 127.0.0.11 valid=2s ipv6=off;
upstream api_backend {
zone api_backend 64k;
server api:8080 resolve max_fails=3 fail_timeout=2s;
keepalive 32;
}
server {
listen 8080;
# The API enforces 10 MiB; leave a little room for HTTP framing.
client_max_body_size 12m;
location / {
proxy_pass http://api_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 2s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
# Do not retry non-idempotent requests transparently. The client
# repeats an uncertain POST with the same Idempotency-Key, which is
# the contract-level guarantee across replicas. Application 503
# responses pass through unchanged.
proxy_next_upstream error timeout http_502 http_504;
proxy_next_upstream_tries 2;
proxy_next_upstream_timeout 3s;
}
}
}
+49
View File
@@ -0,0 +1,49 @@
#!/bin/sh
# Generate the SeaweedFS S3 identity file from local Compose secrets, then run
# one master + volume + filer + S3 process. The file lives only in /tmp; the
# repository never contains credentials.
set -eu
: "${S3_ADMIN_ACCESS_KEY_ID:?missing S3_ADMIN_ACCESS_KEY_ID}"
: "${S3_ADMIN_SECRET_ACCESS_KEY:?missing S3_ADMIN_SECRET_ACCESS_KEY}"
: "${S3_ACCESS_KEY_ID:?missing S3_ACCESS_KEY_ID}"
: "${S3_SECRET_ACCESS_KEY:?missing S3_SECRET_ACCESS_KEY}"
case "$S3_ADMIN_ACCESS_KEY_ID$S3_ADMIN_SECRET_ACCESS_KEY$S3_ACCESS_KEY_ID$S3_SECRET_ACCESS_KEY" in
*[!A-Za-z0-9._-]*)
echo "S3 credentials must contain only A-Z a-z 0-9 . _ -" >&2
exit 1
;;
esac
umask 077
cat > /tmp/s3.json <<EOF
{
"identities": [
{
"name": "admin",
"credentials": [
{"accessKey": "$S3_ADMIN_ACCESS_KEY_ID", "secretKey": "$S3_ADMIN_SECRET_ACCESS_KEY"}
],
"actions": ["Admin", "Read", "Write", "List", "Tagging"]
},
{
"name": "app",
"credentials": [
{"accessKey": "$S3_ACCESS_KEY_ID", "secretKey": "$S3_SECRET_ACCESS_KEY"}
],
"actions": ["Read", "Write", "List"]
}
]
}
EOF
exec /usr/bin/weed -logtostderr=true server \
-dir=/data \
-volume.max=0 \
-master.volumePreallocate \
-master.volumeSizeLimitMB=1024 \
-filer \
-s3 \
-s3.port=8333 \
-s3.config=/tmp/s3.json