First commit on Mac Mini server
This commit is contained in:
31
content/en/projects/self_host/_index.md
Normal file
31
content/en/projects/self_host/_index.md
Normal file
@@ -0,0 +1,31 @@
|
||||
+++
|
||||
title = 'Self-host Projects'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
weight = 90
|
||||
+++
|
||||
|
||||
I’ve recently been exploring the world of self-hosted solutions, and it’s nothing short of amazing. There are some great collections out there that showcase powerful, privacy-respecting tools you can run on your own hardware:
|
||||
- [A collection on GitHub](https://github.com/awesome-selfhosted/awesome-selfhosted)
|
||||
- [selfh.st](https://selfh.st/)
|
||||
|
||||
## ❓ Why Self-Host?
|
||||
|
||||
I enjoy automating tasks and making my life smarter with scripts and small tools. Having control over the services I use, running them on my own hardware, and customizing everything to suit my needs—it’s both empowering and educational.
|
||||
|
||||
|
||||
<!-- ## 🧠 My Home Lab Vision
|
||||
|
||||
I’m currently running some of my own projects on lightweight setups, but I have a bigger plan in mind: a dedicated, used physical server. That will take more time and energy to set up properly, so I’ve decided to gamify the process. -->
|
||||
|
||||
<!-- 🎯 Goal: Once I’ve built 10 great and interesting projects, with at least 3 generating income, I’ll reward myself by setting up a real home lab server.
|
||||
|
||||
Projects:
|
||||
🟩⬜⬜⬜⬜⬜⬜⬜⬜⬜ (1/10)
|
||||
Income Goals:
|
||||
⬜⬜⬜ (0/3) -->
|
||||
|
||||
I’ll use this space to document the projects I build and share what I learn along the way.
|
||||
|
||||
|
||||
## List
|
||||
BIN
content/en/projects/self_host/feature.png
Normal file
BIN
content/en/projects/self_host/feature.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 967 KiB |
@@ -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 |
15
content/en/projects/self_host/stock_bot/01_todo.md
Normal file
15
content/en/projects/self_host/stock_bot/01_todo.md
Normal file
@@ -0,0 +1,15 @@
|
||||
+++
|
||||
title = 'TODO List'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
series = ["StockBot"]
|
||||
series_order = 1
|
||||
weight = 10
|
||||
+++
|
||||
|
||||
## Short-term TODO
|
||||
- 🚧 The Initial Policy implement (Parameterizing transaction variables)
|
||||
- ⬜️ The evaluate & logger script
|
||||
- ⬜ The automatic scripts with Email Sender deployed on the Server
|
||||
- ⬜ Web UI, will not be too complex just a simple one to synchronous my account for customized policy
|
||||
- ⬜️ Implement RL algorithms
|
||||
10
content/en/projects/self_host/stock_bot/02_results.md
Normal file
10
content/en/projects/self_host/stock_bot/02_results.md
Normal file
@@ -0,0 +1,10 @@
|
||||
+++
|
||||
title = 'Showcases'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
series = ["StockBot"]
|
||||
series_order = 2
|
||||
weight = 20
|
||||
+++
|
||||
|
||||
This section will feature occasional showcases of my technical achievements—focused purely on the engineering side, not the income.
|
||||
20
content/en/projects/self_host/stock_bot/_index.md
Normal file
20
content/en/projects/self_host/stock_bot/_index.md
Normal file
@@ -0,0 +1,20 @@
|
||||
+++
|
||||
title = 'StockBot'
|
||||
date = 2024-09-20T04:17:50Z
|
||||
draft = false
|
||||
tags = ["Private", "Ongoing", "Original", "AI"]
|
||||
weight = 10
|
||||
+++
|
||||
|
||||
This is a bot that assists in making daily index fund trading decisions.
|
||||
|
||||
## Introduction
|
||||
|
||||
This project was inspired by my mother. Over the course of ten years, she watched my father struggle in the stock market. From those hard lessons, she developed her own strategy—one that focuses on the predictable fluctuations in index fund values. Armed with nothing more than paper, a pen, and a calculator, she’s been able to achieve steady profits.
|
||||
|
||||
I believe there’s even more potential here.
|
||||
|
||||
By digitizing her process and gradually introducing quantifiable algorithms, I hope to both increase efficiency and explore new edges for profitability. My strategy might cause others' losses, so this project is private permanently.
|
||||
|
||||
## List
|
||||
Here, I’ll keep track of the to-do list and showcase the results as the project evolves. I’ll also highlight some interesting technical insights along the way.
|
||||
BIN
content/en/projects/self_host/stock_bot/feature.png
Normal file
BIN
content/en/projects/self_host/stock_bot/feature.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
Reference in New Issue
Block a user