Try   HackMD

Online Judge 部署 & HTTPS 設定教學

Clone the repo

ref: 青島大學 OnlineJudge

git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git
cd OnlineJudgeDeploy

取得 SSL 證書

由於之前的教學使用的 zerossl 開始要收費,這邊是用 let's encrypt 所維護的 certbot 工具來取得 ssl 證書

先確認你有安裝 brew

安裝 certbot

brew install certbot

可能會安裝一陣子 請有耐心

生成SSL證書

執行這步前先確認目前 80 port 沒有在被使用中,如果你前面不小心把 docker run 起來了話,請先停用它

sudo certbot certonly --standalone

照著提示輸入 email (亂填應該沒差) 還有要註冊的域名
e.g. mozart.ee.ntu.edu.tw
最後應該就會出現以下資訊:

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/mozart.ee.ntu.edu.tw/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/mozart.ee.ntu.edu.tw/privkey.pem
This certificate expires on 2024-02-19.
These files will be updated when the certificate renews.

網站啟用 HTTPS

把上一步產生的 fullchain.pemprivkey.pem 傳進 OnlineJudgeDeploy/data/backend/ssl

sudo cp /YourPathTo/fullchain.pem data/backend/ssl/server.crt
sudo cp /YourPathTo/privkey.pem data/backend/ssl/server.key
sudo chmod 666 data/backend/ssl/server.*

打開docker-compose.yml把其中FORCE_HTTPS=1取消註解

OJ 啟動!

sudo docker-compose up -d

如果跳錯可能是 docker 沒打開,這兩台 mac mini 都是裝 GUI 版的 docker engine ==

90 天候證書過期可以回到 生成 SSL 證書 這步更新