Commit 69010b4978c24ae7ee8e971d6116825dea59e5d7
Exists in
master
Merge branch 'master' of git.ucsd.edu:110swag/flashy-backend
Showing 5 changed files Inline Diff
flashy/wsgi.py
View file @
69010b4
""" | 1 | 1 | """ | |
WSGI config for flashy project. | 2 | 2 | WSGI config for flashy project. | |
3 | 3 | |||
It exposes the WSGI callable as a module-level variable named ``application``. | 4 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. | |
5 | 5 | |||
For more information on this file, see | 6 | 6 | For more information on this file, see | |
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ | 7 | 7 | https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ | |
""" | 8 | 8 | """ | |
9 | 9 | |||
import os | 10 | 10 | import os |
flashy/wsgi_django.py
View file @
69010b4
File was created | 1 | import os | ||
2 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "flashy.settings") | |||
3 | from django.core.wsgi import get_wsgi_application | |||
4 | application = get_wsgi_application() |
flashy/wsgi_websocket.py
View file @
69010b4
File was created | 1 | import os | ||
2 | import gevent.socket | |||
3 | import redis.connection | |||
4 | redis.connection.socket = gevent.socket | |||
5 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "flashy.settings") | |||
6 | from ws4redis.uwsgi_runserver import uWSGIWebsocketServer | |||
7 | application = uWSGIWebsocketServer() |
nginxconf/flashy.cards
View file @
69010b4
upstream backend_production { | 1 | 1 | upstream backend_production { | |
# server unix:/tmp/flashy.sock; | 2 | 2 | # server unix:/tmp/flashy.sock; | |
server localhost:7002; | 3 | 3 | server localhost:7002; | |
} | 4 | 4 | } | |
5 | 5 | |||
6 | upstream websocket_production { | |||
7 | server localhost:7001; | |||
8 | } | |||
9 | ||||
server { | 6 | 10 | server { | |
7 | 11 | |||
server_name flashy.cards; | 8 | 12 | server_name flashy.cards; | |
listen 443 ssl; | 9 | 13 | listen 443 ssl; | |
10 | 14 | |||
11 | 15 | |||
location / { | 12 | 16 | location / { | |
root /srv/flashy.cards/; | 13 | 17 | root /srv/flashy.cards/; | |
index index.html /docs/_h5ai/server/php/index.php; | 14 | 18 | index index.html /docs/_h5ai/server/php/index.php; | |
location ~ \.php$ { | 15 | 19 | location ~ \.php$ { | |
try_files $uri =404; | 16 | 20 | try_files $uri =404; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | 17 | 21 | fastcgi_pass unix:/var/run/php5-fpm.sock; | |
include fastcgi_params; | 18 | 22 | include fastcgi_params; | |
} | 19 | 23 | } | |
} | 20 | 24 | } | |
21 | 25 | |||
location ^~ /static { | 22 | 26 | location ^~ /static { | |
root /srv/; | 23 | 27 | root /srv/; | |
access_log off; | 24 | 28 | access_log off; | |
expires 30d; | 25 | 29 | expires 30d; | |
} | 26 | 30 | } | |
27 | 31 | |||
location ^~ /app/ { | 28 | 32 | location ^~ /app/ { | |
alias /srv/flashy-frontend/; | 29 | 33 | alias /srv/flashy-frontend/; | |
try_files $uri /app/home.html; | 30 | 34 | try_files $uri /app/home.html; | |
35 | } | |||
36 | ||||
37 | location /ws/ { | |||
38 | proxy_http_version 1.1; | |||
39 | proxy_set_header Upgrade $http_upgrade; | |||
40 | proxy_set_header Connection "upgrade"; | |||
41 | proxy_pass http://websocket_production; | |||
} | 31 | 42 | } | |
32 | 43 | |||
location ~ /(api|admin|api-auth)/ { | 33 | 44 | location ~ /(api|admin|api-auth)/ { | |
add_header 'Access-Control-Allow-Origin' 'http://localhost'; | 34 | 45 | add_header 'Access-Control-Allow-Origin' 'http://localhost'; | |
add_header 'Access-Control-Allow-Credentials' 'true'; | 35 | 46 | add_header 'Access-Control-Allow-Credentials' 'true'; | |
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PATCH, PUT'; | 36 | 47 | add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PATCH, PUT'; | |
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,Origin,Authorization,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-CSRFToken'; | 37 | 48 | add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,Origin,Authorization,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-CSRFToken'; | |
proxy_pass http://backend_production; | 38 | 49 | proxy_pass http://backend_production; | |
proxy_redirect http://backend_production $scheme://flashy.cards; | 39 | 50 | proxy_redirect http://backend_production $scheme://flashy.cards; | |
proxy_set_header Host $host; | 40 | 51 | proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | 41 | 52 | proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | 42 | 53 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | 43 | 54 | proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header REMOTE_ADDR $remote_addr; | 44 | 55 | proxy_set_header REMOTE_ADDR $remote_addr; | |
} | 45 | 56 | } | |
46 | 57 | |||
location ^~ /jenkins { | 47 | 58 | location ^~ /jenkins { | |
proxy_pass http://localhost:8080; | 48 | 59 | proxy_pass http://localhost:8080; | |
proxy_redirect http://localhost:8080 $scheme://flashy.cards; | 49 | 60 | proxy_redirect http://localhost:8080 $scheme://flashy.cards; | |
proxy_set_header Host $host; | 50 | 61 | proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | 51 | 62 | proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | 52 | 63 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | 53 | 64 | proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_read_timeout 90; | 54 | 65 | proxy_read_timeout 90; | |
} | 55 | 66 | } | |
ssl_certificate /etc/nginx/ssl/bundle.crt; | 56 | 67 | ssl_certificate /etc/nginx/ssl/bundle.crt; | |
ssl_certificate_key /etc/nginx/ssl/nginx.key; | 57 | 68 | ssl_certificate_key /etc/nginx/ssl/nginx.key; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | 58 | 69 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS; | 59 | 70 | ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS; | |
ssl_prefer_server_ciphers on; | 60 | 71 | ssl_prefer_server_ciphers on; | |
keepalive_timeout 70; | 61 | 72 | keepalive_timeout 70; | |
ssl_session_cache shared:SSL:10m; | 62 | 73 | ssl_session_cache shared:SSL:10m; |
scripts/run_production.sh
View file @
69010b4
#!/bin/bash -xe | 1 | 1 | #!/bin/bash -xe | |
source secrets.sh | 2 | 2 | source secrets.sh | |
source venv/bin/activate | 3 | 3 | source venv/bin/activate | |
# newrelic-admin run-program /srv/flashy-backend/venv/bin/gunicorn --pid /run/flashy/gunicorn.pid -w 6 -n flashy -b 127.0.0.1:7002 flashy.wsgi | 4 | 4 | # newrelic-admin run-program /srv/flashy-backend/venv/bin/gunicorn --pid /run/flashy/gunicorn.pid -w 6 -n flashy -b 127.0.0.1:7002 flashy.wsgi | |
5 | uwsgi /etc/uwsgi/websocket.ini --touch-reload=/etc/uwsgi/websocket.ini & | |||
newrelic-admin run-program uwsgi /etc/uwsgi/flashy.ini --touch-reload=/etc/uwsgi/flashy.ini | 5 | 6 | newrelic-admin run-program uwsgi /etc/uwsgi/flashy.ini --touch-reload=/etc/uwsgi/flashy.ini |