77 lines
2.4 KiB
Markdown
77 lines
2.4 KiB
Markdown
# 🗂️ Trashbox - Минималистичный файловый сервер
|
|
|
|
### Установка зависимостей
|
|
``` bash
|
|
sudo apt update
|
|
sudo apt install nginx busybox gcc
|
|
```
|
|
### Настройка структуры
|
|
```bash
|
|
mkdir -p /home/romkazvo/www/cgi-bin
|
|
cd /home/romkazvo/www/cgi-bin
|
|
```
|
|
### Компиляция CGI приложений
|
|
```bash
|
|
gcc -o index.cgi index.c
|
|
gcc -o style.cgi style.c
|
|
gcc -o status.cgi status.c
|
|
chmod +x *.cgi
|
|
```
|
|
### Конфигурация Nginx
|
|
Создайте файл конфигурации `/etc/nginx/sites-available/trashbox`:
|
|
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name home.mashup.su www.home.mashup.su;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/www.home.mashup.su/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/www.home.mashup.su/privkey.pem;
|
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384;
|
|
|
|
location = /gachi {
|
|
proxy_pass http://127.0.0.1:8001/;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_read_timeout 3600;
|
|
proxy_send_timeout 3600;
|
|
add_header X-Stream-Name "Gachi Stream" always;
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, OPTIONS, HEAD" always;
|
|
add_header Access-Control-Allow-Headers "Range, Accept-Encoding" always;
|
|
}
|
|
|
|
location /cgi-bin/ {
|
|
proxy_pass http://127.0.0.1:8050;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8050;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name home.mashup.su www.home.mashup.su;
|
|
return 301 https://$server_name$request_uri;
|
|
}
|
|
|
|
|
|
### Запуск BusyBox
|
|
```bash
|
|
busybox httpd -p 127.0.0.1:8050 -h /home/romkazvo/www
|
|
```
|