| refactor: clean up code, add systemd service, and write comprehensive README

This commit is contained in:
2026-05-19 17:44:14 +03:00
parent 0519ba4908
commit 9660cfa41b
3 changed files with 338 additions and 71 deletions

View File

@@ -0,0 +1,50 @@
# /etc/systemd/system/corsproxy.service
#
# Systemd unit for the Unsloth Studio CORS proxy.
#
# Installation:
# sudo cp corsproxy.service /etc/systemd/system/
# sudo systemctl daemon-reload
# sudo systemctl enable corsproxy.service # start on boot
# sudo systemctl start corsproxy.service # start now
#
# Management:
# sudo systemctl status corsproxy.service # view status
# sudo journalctl -u corsproxy.service -f # follow logs
# sudo systemctl restart corsproxy.service # restart
[Unit]
Description=Unsloth Studio CORS Proxy
Documentation=https://github.com/NikkeDoy/CORSProxy
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /opt/CORSProxy/main.py --target 127.0.0.1:8888 --listen 8080
WorkingDirectory=/opt/CORSProxy
Restart=on-failure
RestartSec=5
# --- Hardening ---
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
ReadWritePaths=/var/log/corsproxy
CapabilityBoundingSet=
AmbientCapabilities=CAP_NET_BIND_SERVICE
# --- Tunable ---
# Override by creating a drop-in:
# sudo systemctl edit corsproxy.service
#
# Add:
# [Service]
# ExecStart=
# ExecStart=/usr/bin/python3 /opt/CORSProxy/main.py --target 10.0.0.5:8000 --listen 9090
# --- Restart limiter ---
StartLimitIntervalSec=300
StartLimitBurst=5
[Install]
WantedBy=multi-user.target