v0.0.1
This commit is contained in:
261
README.md
Normal file
261
README.md
Normal file
@@ -0,0 +1,261 @@
|
||||
# Start
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
```
|
||||
sudo apt upgrade -y
|
||||
```
|
||||
|
||||
```
|
||||
sudo apt install -y curl gnupg2 ca-certificates lsb-release
|
||||
```
|
||||
|
||||
```
|
||||
sudo apt install zip
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Docker Install
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
sudo apt install -y docker.io
|
||||
sudo systemctl enable --now docker
|
||||
sudo usermod -aG docker $USER
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Docker Compose Install
|
||||
|
||||
```
|
||||
sudo apt install -y docker-compose
|
||||
```
|
||||
|
||||
```
|
||||
docker-compose --version
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Start Sheep-Service
|
||||
|
||||
```
|
||||
cd /home/rozenrod/webapps/sheep-service.com
|
||||
```
|
||||
|
||||
```
|
||||
docker-compose pull && docker-compose -p Sheep-Service up --build -d
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# NGINX Install
|
||||
|
||||
```
|
||||
sudo apt install nginx
|
||||
```
|
||||
|
||||
```
|
||||
sudo systemctl status nginx
|
||||
```
|
||||
|
||||
```
|
||||
sudo systemctl enable nginx
|
||||
```
|
||||
|
||||
```
|
||||
sudo nano /etc/nginx/nginx.conf
|
||||
```
|
||||
|
||||
```
|
||||
proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=all:5m inactive=10m max_size=2g;
|
||||
|
||||
limit_req_zone $binary_remote_addr zone=one:5m rate=30r/s;
|
||||
client_max_body_size 20M;
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
```
|
||||
set_real_ip_from 103.21.244.0/22;
|
||||
set_real_ip_from 103.22.200.0/22;
|
||||
set_real_ip_from 103.31.4.0/22;
|
||||
set_real_ip_from 104.16.0.0/13;
|
||||
set_real_ip_from 104.24.0.0/14;
|
||||
set_real_ip_from 108.162.192.0/18;
|
||||
set_real_ip_from 131.0.72.0/22;
|
||||
set_real_ip_from 141.101.64.0/18;
|
||||
set_real_ip_from 162.158.0.0/15;
|
||||
set_real_ip_from 172.64.0.0/13;
|
||||
set_real_ip_from 173.245.48.0/20;
|
||||
set_real_ip_from 188.114.96.0/20;
|
||||
set_real_ip_from 190.93.240.0/20;
|
||||
set_real_ip_from 197.234.240.0/22;
|
||||
set_real_ip_from 198.41.128.0/17;
|
||||
set_real_ip_from 2400:cb00::/32;
|
||||
set_real_ip_from 2606:4700::/32;
|
||||
set_real_ip_from 2803:f800::/32;
|
||||
set_real_ip_from 2405:b500::/32;
|
||||
set_real_ip_from 2405:8100::/32;
|
||||
set_real_ip_from 2a06:98c0::/29;
|
||||
set_real_ip_from 2c0f:f248::/32;
|
||||
|
||||
#real_ip_header CF-Connecting-IP;
|
||||
real_ip_header X-Forwarded-For;
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# NGINX Settings WEB
|
||||
|
||||
```
|
||||
sudo nano /etc/nginx/sites-available/sheep-service.com
|
||||
```
|
||||
|
||||
```
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name sheep-service.com www.sheep-service.com;
|
||||
|
||||
error_log /home/rozenrod/webapps/log/sheep-service.com.error.log error;
|
||||
access_log /home/rozenrod/webapps/log/sheep-service.com.access.log;
|
||||
|
||||
root /home/rozenrod/webapps/sheep-service.com;
|
||||
|
||||
index index.html;
|
||||
|
||||
error_page 404 /404.html;
|
||||
|
||||
location ~ /\.git {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~ /\.env {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:4000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
|
||||
add_header 'Access-Control-Max-Age' 1728000;
|
||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
if ($request_method = 'PUT') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
}
|
||||
if ($request_method = 'POST') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
}
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
}
|
||||
if ($request_method = 'DELETE') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
}
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:4001;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:4002;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
sudo ln -s /etc/nginx/sites-available/sheep-service.com /etc/nginx/sites-enabled/sheep-service.com
|
||||
```
|
||||
|
||||
```
|
||||
sudo nginx -t
|
||||
```
|
||||
|
||||
```
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Certbot Install
|
||||
|
||||
```
|
||||
sudo python3 -m venv /opt/certbot/
|
||||
```
|
||||
|
||||
```
|
||||
sudo /opt/certbot/bin/pip install --upgrade pip
|
||||
```
|
||||
|
||||
```
|
||||
sudo /opt/certbot/bin/pip install certbot certbot-nginx
|
||||
```
|
||||
|
||||
```
|
||||
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
|
||||
```
|
||||
|
||||
```
|
||||
sudo certbot --nginx -d sheep-service.com
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
|
||||
```
|
||||
|
||||
```
|
||||
sudo /opt/certbot/bin/pip install --upgrade certbot certbot-nginx
|
||||
```
|
||||
Reference in New Issue
Block a user