fix: Errors with service and nginx

This commit is contained in:
Nathan Woodburn 2024-02-23 14:42:15 +11:00
parent 70ab871e63
commit 2f75f3d641
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
4 changed files with 30 additions and 11 deletions

View File

@ -1 +1,20 @@
# site-manager # site-manager
Installation
------------
```bash
wget https://git.woodburn.au/nathanwoodburn/site-manager/raw/branch/main/install.sh
chmod +x install.sh
sudo ./install.sh
```
Create account
--------------
Accounts can only be created by the root user
```bash
sudo -i
cd /root/site-manager
python3 account.py
exit
```

View File

@ -8,15 +8,15 @@ fi
# Install nginx # Install nginx
sudo apt update sudo apt update
sudo apt install nginx -y sudo apt install nginx python3-pip -y
cd /root cd /root
git clone https://git.woodburn.au/nathanwoodburn/site-manager.git git clone https://git.woodburn.au/nathanwoodburn/site-manager.git
cd site-manager cd site-manager
chmod +x *.sh chmod +x *.sh
python3 -m pip install -r requirements.txt
# Install python script as a service # Install python script as a service
sudo cp ./nginx-traffic-monitor.service /etc/systemd/system/nginx-traffic-monitor.service sudo cp ./nginx-manager.service /etc/systemd/system/nginx-manager.service
sudo systemctl start nginx-traffic-monitor] sudo systemctl start nginx-manager
sudo systemctl enable nginx-traffic-monitor sudo systemctl enable nginx-manager

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=NGINX Traffic Monitor Description=NGINX Manager
After=network.target After=network.target
[Service] [Service]
@ -7,8 +7,8 @@ Type=simple
ExecStart=/usr/bin/python3 /root/site-manager/main.py ExecStart=/usr/bin/python3 /root/site-manager/main.py
WorkingDirectory=/root/site-manager WorkingDirectory=/root/site-manager
Restart=always Restart=always
User=nginx User=root
Group=nginx Group=root
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -161,7 +161,7 @@ def write_nginx_conf(site):
server {{ server {{
listen 80; listen 80;
listen [::]:80; listen [::]:80;
root {location}; root '{location}';
index index.html; index index.html;
server_name {domain} *.{domain}; server_name {domain} *.{domain};
@ -197,7 +197,7 @@ def write_nginx_conf(site):
server {{ server {{
listen 80; listen 80;
listen [::]:80; listen [::]:80;
root {location}; root '{location}';
index index.html; index index.html;
server_name {alt} *.{alt}; server_name {alt} *.{alt};
@ -225,7 +225,7 @@ def write_nginx_conf(site):
ssl_certificate_key /root/site-manager/certs/{alt}.key; ssl_certificate_key /root/site-manager/certs/{alt}.key;
}} }}
''' '''
with open(f'/etc/nginx/sites-available/{id}.conf', 'w') as file: with open(f'/etc/nginx/sites-enabled/{id}.conf', 'w') as file:
file.write(conf) file.write(conf)
# Restart nginx # Restart nginx