Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update opinionated nginx.conf changes, and add an example systemd uni… #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions misc/kcdcpython.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Runs the gunicorn process for KCDC website
After=nginx.service mysql.service

[Service]
PIDFile=/srv/www/production/var/gunicorn.pid
Type=forking
User=www-data
Group=www-data
ExecStart=/bin/bash -c 'cd /srv/www/production && source venv/bin/activate ; /srv/www/production/manage.py run_gunicorn --pid=/srv/www/production/var/gunicorn.pid --access-logfile=/srv/www/production/var/access.log --error-logfile=/srv/www/production/var/error.log --log-level=INFO --bind=127.0.0.1:8000 --daemon'
TimeoutStopSec=10
KillMode=mixed

[Install]
WantedBy=multi-user.target
51 changes: 26 additions & 25 deletions misc/nginx-sites-enabled-kcdc.conf
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
upstream production_app_server {
server 127.0.0.1:8001 fail_timeout=0;
server 127.0.0.1:8000 fail_timeout=0;
}

server {
listen 80; ## listen for ipv4; this line is default and implied
client_max_body_size 4G;
server_name knowledgecommonsdc.org;
listen 80; ## listen for ipv4; this line is default and implied
client_max_body_size 4G;
server_name knowledgecommonsdc.org;

keepalive_timeout 5;
keepalive_timeout 5;

root /srv/www/production/kcdc/kcdc3/kcdc3/public;
root /srv/www/production/kcdc3/public;


# I think this should be blank, to match anything
# I think this should be blank, to match anything
location / {
try_files $uri @proxy_to_app;
}
try_files $uri @proxy_to_app;
}

location = /static/ {
root /srv/www/production/kcdc/kcdc3/kcdc3/public/static;
expires 30d; # suggested, i guess we can do whenever
root /srv/www/production/kcdc3/public/static;
expires 30d; # suggested, i guess we can do whenever
}

location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

proxy_pass http://production_app_server;
}

error_page 500 502 503 504 /500.html;
location /500.html {
root /srv/www/production/kcdc3/kcdc3/public;
}

location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

proxy_pass http://production_app_server;
}

error_page 500 502 503 504 /500.html;
location /500.html {
root /srv/www/production/kcdc3/kcdc3/public;
}

}