Files
2026-10-25 00:35:17 +08:00

84 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SimpleRickroll
Simple static webpage for playing Rickroll | 播放瑞克搖的簡易靜態網站
掛在網域根目錄(`https://sthkm3.org`)的誘餌頁面。任何路徑都會回一個標題為 "About" 的頁面並播放 Rick Astley,讓亂逛的人和掃描 `/wp-admin`、`/.env` 的機器人吃到 rickroll。
純靜態網站:沒有後端、沒有資料、不掛載任何路徑。
![點進網站後的畫面](img/image.png)
## 檔案
| 檔案 | 說明 |
| --- | --- |
| `Dockerfile` | 以 `nginxinc/nginx-unprivileged:stable-alpine` 為基底,非 root(uid 101)執行 |
| `nginx.conf` | 監聽 `1000`;所有路徑回 `index.html`;只允許 GET/HEAD,其他回 405;隱藏版本號 |
| `index.htm` | 頁面。先嘗試有聲播放,被瀏覽器擋下就靜音播放,使用者第一次點擊/按鍵時開聲音 |
| `rickroll.mp4` | 960×720 60fps H.264 + AAC,約 28MB,faststart |
## 本地測試
```sh
docker build -t simplerickroll:local .
docker run -d --name simplerickroll \
--read-only --tmpfs /tmp \
--cap-drop ALL --security-opt no-new-privileges \
--memory 64m --pids-limit 64 \
-p 127.0.0.1:1000:1000 simplerickroll:local
```
打開 <http://127.0.0.1:1000/>。
## 發布 image
Image 放在 Gitea 內建的 container registry。
```sh
docker login gitea.sthkm3.org
docker build -t gitea.sthkm3.org/sthkm3/simplerickroll:1.0.0 .
docker push gitea.sthkm3.org/sthkm3/simplerickroll:1.0.0
```
## 部署(TrueNAS SCALE Apps)
Apps → Discover Apps → ⋮ → Install via YAML。
容器只接在 `cloudflared_proxy` 網路上,不對外開 port,只有 cloudflared 能連到。Cloudflare Tunnel 的 service 設為 `http://rickroll:1000`。
```yaml
services:
rickroll:
image: gitea.sthkm3.org/sthkm3/simplerickroll:1.0.0
container_name: rickroll
restart: unless-stopped
read_only: true
tmpfs: [/tmp]
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
mem_limit: 64m
pids_limit: 64
networks: [cloudflared_proxy]
networks:
cloudflared_proxy:
external: true
```
更新時推新的 tag,再到 TrueNAS 編輯 app 改 `image:` 的 tag。偶爾重新 build 以取得 nginx 安全更新。
## 更換影片
影片直接進 git,不用 Git LFS,clone 下來就能直接 build。保持 H.264 + AAC 的 mp4,Safari / iOS 才能播。
```sh
ffmpeg -i source.mp4 -vf "scale=-2:720:flags=lanczos" -r 60 \
-c:v libx264 -preset slow -crf 28 -maxrate 900k -bufsize 1800k \
-profile:v high -level 4.2 -pix_fmt yuv420p -g 120 \
-c:a aac -b:a 128k -ac 2 -movflags +faststart rickroll.mp4
```
## 注意
這個頁面只保護根網域,**擋不住對子網域的直接攻擊**。子網域可以從憑證透明度紀錄或 DNS 爆破找到,公開服務(n8n、crafty 等)仍需各自更新與防護,例如用 Cloudflare Access 鎖住管理介面、只放行必要路徑。