First commit on Mac Mini server
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
+++
|
||||
title = 'Website Setup'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
series = ["My First Server in Room"]
|
||||
series_order = 1
|
||||
weight = 10
|
||||
+++
|
||||
|
||||
I don't have a public IP, so my solution is SSH tunnel + reverse Proxy on cloud server.
|
||||
|
||||
## 🍎Mac Mini Side
|
||||
As a server, my Mac won't sleep, so change the setting firstly.
|
||||
```
|
||||
sudo systemsetup -setcomputersleep Never # never sleep
|
||||
sudo systemsetup -setdisplaysleep 10 # display will sleep in 10 min
|
||||
```
|
||||
|
||||
Use autossh to avoid timeout:
|
||||
```
|
||||
brew install autossh
|
||||
```
|
||||
|
||||
Add the configuration below in `~/.ssh/config`, Mac Mini will send package per 30 seconds to keep the connection alive.
|
||||
```
|
||||
Host <ip address>
|
||||
ServerAliveInterval 30
|
||||
ServerAliveCountMax 5
|
||||
TCPKeepAlive yes
|
||||
```
|
||||
|
||||
Build the connection:
|
||||
```
|
||||
autossh -M 0 -f -N \
|
||||
-i ~/.ssh/id_ed25519 \
|
||||
-o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" \
|
||||
-R 0.0.0.0:9000:localhost:1313 \
|
||||
root@<ip address>
|
||||
```
|
||||
```
|
||||
autossh -M 0 -f -N -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 0.0.0.0:9000:localhost:1313 user@<your.server.com>
|
||||
```
|
||||
|
||||
A watchdog script to try reconnection when the network lost(add to LaunchAgent):
|
||||
```
|
||||
#!/bin/bash
|
||||
while true; do
|
||||
ping -c 1 <ip address> > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
pkill -f autossh
|
||||
autossh -M 0 -f -N -R 0.0.0.0:9000:localhost:1313 <ip address>
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
```
|
||||
|
||||
|
||||
## 💻Server Side
|
||||
Install and config the Nginx, for me the config file in `/etc/nginx/sites-available`:
|
||||
```
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.<your domain> <your domain>;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:9000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To obtain a security certificate, use the certbot:
|
||||
```
|
||||
sudo apt update
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
sudo certbot --nginx -d swangnice.cn
|
||||
```
|
||||
|
||||
|
||||
33
content/en/projects/self_host/mac_mini_m4/02_nas.md
Normal file
33
content/en/projects/self_host/mac_mini_m4/02_nas.md
Normal file
@@ -0,0 +1,33 @@
|
||||
+++
|
||||
title = 'NAS: Network Attachment Storage'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
series = ["My First Server in Room"]
|
||||
series_order = 2
|
||||
weight = 20
|
||||
+++
|
||||
|
||||
## Hardware
|
||||
I went with the UNITEK 3373BBK for one of my drive enclosures—and honestly, it wasn’t the best decision.
|
||||
|
||||
The first big letdown? The bandwidth tops out at just 5Gbps. That’s fine for basic tasks, but definitely underwhelming if you’re dealing with high-speed storage or large file transfers.
|
||||
|
||||
Even worse, it doesn’t support S.M.A.R.T passthrough, which makes monitoring drive health a hassle. That was a big deal-breaker for me.
|
||||
|
||||
Still, none of the other options really fit my expectations either. One day, I might just go all-in and make my own enclosure—design the PCB, write the firmware, the whole deal. Maybe not today… but someday.
|
||||
|
||||
|
||||
```
|
||||
diskutil list
|
||||
```
|
||||
|
||||
Solution: HFS+ + SMB3.0, 客户端设置“延迟加载目录”或“按需索引”
|
||||
|
||||
```diskutil list```
|
||||
|
||||
```
|
||||
sudo smartctl -a /dev/disk2
|
||||
```
|
||||
|
||||
```brew install smartmontools```
|
||||
|
||||
43
content/en/projects/self_host/mac_mini_m4/03_gitea.md
Normal file
43
content/en/projects/self_host/mac_mini_m4/03_gitea.md
Normal file
@@ -0,0 +1,43 @@
|
||||
+++
|
||||
title = 'My Own Code Vault: Gitea on Mac Mini'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
series = ["My First Server in Room"]
|
||||
series_order = 3
|
||||
weight = 30
|
||||
+++
|
||||
|
||||
Install dependence of gitea:
|
||||
```
|
||||
brew install git
|
||||
brew install gitea
|
||||
```
|
||||
|
||||
Start the configuration page of Gitea:
|
||||
```
|
||||
gitea web
|
||||
```
|
||||
|
||||
Install MySQL:
|
||||
```
|
||||
brew install mysql
|
||||
brew services start mysql
|
||||
```
|
||||
|
||||
Login MySQL and create the database and user:
|
||||
```
|
||||
mysql -u root
|
||||
```
|
||||
Then, execute:
|
||||
```
|
||||
CREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
CREATE USER 'gitea'@'localhost' IDENTIFIED BY '<yourpassword>';
|
||||
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
|
||||
CREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'gitea';
|
||||
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
13
content/en/projects/self_host/mac_mini_m4/_index.md
Normal file
13
content/en/projects/self_host/mac_mini_m4/_index.md
Normal file
@@ -0,0 +1,13 @@
|
||||
+++
|
||||
title = 'My First Server in Room: Mac Mini + SSD Enclosure'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
tags = ["Public", "Ongoing", "Original", "AI"]
|
||||
weight = 10
|
||||
+++
|
||||
|
||||
For my first physical server in my life, I got an Mac Mini with M4 and an HDD enclosure.
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
content/en/projects/self_host/mac_mini_m4/feature.png
Normal file
BIN
content/en/projects/self_host/mac_mini_m4/feature.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
Reference in New Issue
Block a user