Skip to content

Commit

Permalink
nginx as proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
fdavis committed Jun 22, 2013
1 parent a8e5e7b commit 077d2ed
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
7 changes: 0 additions & 7 deletions django.yml

This file was deleted.

45 changes: 30 additions & 15 deletions roles/django/files/django
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug Off
</Location>
# nginx.conf
upstream django {
# connect to this socket
# server unix:///tmp/uwsgi.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket
}

ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name localhost; # substitute your machine's IP address or FQDN
charset utf-8;

</VirtualHost>
#Max upload size
client_max_body_size 75M; # adjust to taste

# Django media
#location /media {
# alias /path/to/your/project/project/media; # your Django project's media files
#}

#location /static {
# alias /path/to/your/project/project/static; # your Django project's static files
#}

# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
}
}
12 changes: 12 additions & 0 deletions roles/django/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,17 @@
tags:
- gitpull

- name: setup django conf for nginx
copy: src=django dest=/etc/nginx/sites-available/django mode=0644 owner=root group=root
notify: service nginx start/enable

- name: symlink from sites enabled
shell: ln -s ../sites-availble/django /etc/nginx/sites-enabled/django creates=/etc/nginx/sites-enabled/django
notify: service nginx start/enable

- name: remove default enabled
file: path=/etc/nginx/sites-enabled/default state=absent
notify: service nginx start/enable

- name: print out some versions
shell: python --version; python -c "import django; print django.VERSION"

0 comments on commit 077d2ed

Please sign in to comment.