Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update readme.md and create nginx_setup.md * Add discord link to readme * Update README.md * nginx_setup.md initial commit * re-add start.sh * Add travis badge to readme. Closes #29 * "Instalation" (Thanks Ben) * Update README.md * Update README.md * remove incomplete tag * Update nginx_setup.md * Delete random underscore in start.sh
- Loading branch information
1 parent
329d017
commit 2451b47
Showing
3 changed files
with
118 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# NGINX setup instructions | ||
|
||
### Note: This document assumes a Debian or Ubuntu system | ||
|
||
## HTTP Setup | ||
|
||
1. Install nginx by running `sudo apt install -y nginx` | ||
2. Save the following to `/etc/nginx/sites-available/olly`. Be sure to replace `example.com` with your domain. (This should be the same as `ALLOWED_HOSTS` in `settings.py`.) | ||
```nginx | ||
server { | ||
listen 80; | ||
client_max_body_size 4G; | ||
server_name example.com; | ||
keepalive_timeout 5; | ||
root /var/www/static; | ||
location /static { | ||
alias /var/www/static; | ||
} | ||
location / { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
proxy_pass http://unix:/tmp/olly.sock; | ||
} | ||
} | ||
``` | ||
3.Create a symlink in the `sites-enabled` directory to the configuration file you just created `sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled` and restart nginx `sudo nginx -s reload` | ||
|
||
## HTTPS setup with Let's Encrypt | ||
|
||
After setting up nginx you will likely want to add HTTPS support | ||
|
||
1. (Ubuntu only, if you are running Debian skip this step.) Run the following commands to add the certbot PPA | ||
```bash | ||
sudo apt-get update | ||
sudo apt-get install -y software-properties-common | ||
sudo add-apt-repository universe | ||
sudo add-apt-repository ppa:certbot/certbot | ||
sudo apt-get update | ||
``` | ||
2. Install certbot `sudo apt install -y certbot python-certbot-nginx` | ||
3. Configure certbot by running `sudo certbot --nginx` and following the prompts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
echo Debug is $debug | ||
|
||
echo Running Migrations. | ||
python3 manage.py migrate | ||
|
||
echo creating a superuser. | ||
python3 manage.py shell -c "from django.contrib.auth import get_user_model; User=get_user_model(); User.objects.filter(pk=1).exists() or User.objects.create_superuser('admin', 'admin@example.com', 'ChangeMe!')" | ||
python3 manage.py shell -c "from profiles.models import UserProfile; up=UserProfile.objects.get(pk=1); up.user_type='superadmin'; up.user_verified=1; up.save()" | ||
|
||
echo creating staticinfo | ||
python3 manage.py shell -c "from pages.models import StaticInfo; StaticInfo.objects.get_or_create(pk=1);" | ||
|
||
echo Collecting static files | ||
python3 manage.py collectstatic --noinput | ||
|
||
echo Starting Gunicorn. | ||
gunicorn olly.wsgi:application \ | ||
--bind unix:/sock/olly.sock \ | ||
--workers 2 |