Skip to content

Instantly share code, notes, and snippets.

@jsutlovic
Created August 10, 2012 20:02
Show Gist options
  • Save jsutlovic/3317395 to your computer and use it in GitHub Desktop.
Save jsutlovic/3317395 to your computer and use it in GitHub Desktop.

Revisions

  1. jsutlovic revised this gist Oct 31, 2012. 2 changed files with 71 additions and 57 deletions.
    51 changes: 0 additions & 51 deletions nginx-debug.conf
    Original file line number Diff line number Diff line change
    @@ -1,51 +0,0 @@
    worker_processes 1;

    events {
    worker_connections 1024;
    }


    http {
    include mime.types;
    default_type application/octet-stream;

    sendfile on;

    keepalive_timeout 720;

    upstream app_server {
    #server unix:/tmp/gunicorn.sock fail_timeout=0;
    server localhost:8000;
    #server localhost:8083;
    }

    server {
    listen 80;
    listen 443 ssl;

    server_name jero.tophatmonocle.com;

    ssl_certificate /usr/local/etc/nginx/ssl/jero.tophatmonocle.com.crt;
    ssl_certificate_key /usr/local/etc/nginx/ssl/jero.tophatmonocle.com.nopass.key;

    root /Users/jero/dev/thm_env/THM;

    location / {
    try_files $uri @proxy_to_app;
    }

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

    proxy_pass http://app_server;
    #uwsgi_pass app_server;
    #include uwsgi_params;
    }
    }


    }
    77 changes: 71 additions & 6 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@

    worker_processes 1;

    events {
    @@ -13,16 +14,32 @@ http {

    keepalive_timeout 65;

    #gzip on;

    upstream app_server {
    upstream uwsgi_server {
    server localhost:8083;
    }

    upstream dev_server {
    server localhost:8000;
    }

    upstream sentry_server {
    server localhost:9000;
    }

    server {
    listen 80;
    server_name dev.jero.tophatmonocle.com;
    return 302 https://dev.jero.tophatmonocle.com$request_uri;
    }

    server {
    listen 80;
    server_name jero.tophatmonocle.com;
    return 302 https://jero.tophatmonocle.com$request_uri;
    }

    server {
    listen 80;
    listen 443 ssl;
    #ssl on;

    server_name jero.tophatmonocle.com;

    @@ -31,14 +48,62 @@ http {

    root /Users/jero/dev/thm_env/THM;

    location /favicon.ico {
    alias /Users/jero/dev/thm_env/THM/media/icon.ico;
    }

    location / {
    try_files $uri @proxy_to_app;
    }

    location @proxy_to_app {
    uwsgi_pass app_server;
    uwsgi_pass uwsgi_server;
    include uwsgi_params;
    }
    }

    server {
    listen 443 ssl;

    server_name dev.jero.tophatmonocle.com;

    ssl_certificate /usr/local/etc/nginx/ssl/wc.jero.tophatmonocle.com.crt;
    ssl_certificate_key /usr/local/etc/nginx/ssl/jero.tophatmonocle.com.nopass.key;

    root /Users/jero/dev/thm_env/THM;

    location / {
    try_files $uri @proxy_to_app;
    }

    location /favicon.ico {
    alias /Users/jero/dev/thm_env/THM/media/icon.ico;
    }

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

    proxy_pass http://dev_server;
    }
    }

    server {
    listen 80;

    server_name sentry.jero.tophatmonocle.com;

    location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Protocol $scheme;
    proxy_read_timeout 60;
    proxy_redirect off;

    proxy_pass http://sentry_server;
    }
    }
    }
  2. jsutlovic revised this gist Sep 2, 2012. 2 changed files with 0 additions and 17 deletions.
    1 change: 0 additions & 1 deletion nginx-debug.conf
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    worker_processes 1;

    events {
    16 changes: 0 additions & 16 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    worker_processes 1;

    events {
    @@ -16,21 +15,6 @@ http {

    #gzip on;

    server {
    listen 8080;
    server_name localhost;

    location / {
    root html;
    index index.html index.htm;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }
    }

    upstream app_server {
    server localhost:8083;
    }
  3. jsutlovic created this gist Aug 10, 2012.
    52 changes: 52 additions & 0 deletions nginx-debug.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@

    worker_processes 1;

    events {
    worker_connections 1024;
    }


    http {
    include mime.types;
    default_type application/octet-stream;

    sendfile on;

    keepalive_timeout 720;

    upstream app_server {
    #server unix:/tmp/gunicorn.sock fail_timeout=0;
    server localhost:8000;
    #server localhost:8083;
    }

    server {
    listen 80;
    listen 443 ssl;

    server_name jero.tophatmonocle.com;

    ssl_certificate /usr/local/etc/nginx/ssl/jero.tophatmonocle.com.crt;
    ssl_certificate_key /usr/local/etc/nginx/ssl/jero.tophatmonocle.com.nopass.key;

    root /Users/jero/dev/thm_env/THM;

    location / {
    try_files $uri @proxy_to_app;
    }

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

    proxy_pass http://app_server;
    #uwsgi_pass app_server;
    #include uwsgi_params;
    }
    }


    }
    60 changes: 60 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@

    worker_processes 1;

    events {
    worker_connections 1024;
    }


    http {
    include mime.types;
    default_type application/octet-stream;

    sendfile on;

    keepalive_timeout 65;

    #gzip on;

    server {
    listen 8080;
    server_name localhost;

    location / {
    root html;
    index index.html index.htm;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }
    }

    upstream app_server {
    server localhost:8083;
    }

    server {
    listen 80;
    listen 443 ssl;
    #ssl on;

    server_name jero.tophatmonocle.com;

    ssl_certificate /usr/local/etc/nginx/ssl/jero.tophatmonocle.com.crt;
    ssl_certificate_key /usr/local/etc/nginx/ssl/jero.tophatmonocle.com.nopass.key;

    root /Users/jero/dev/thm_env/THM;

    location / {
    try_files $uri @proxy_to_app;
    }

    location @proxy_to_app {
    uwsgi_pass app_server;
    include uwsgi_params;
    }
    }

    }
    16 changes: 16 additions & 0 deletions uwsgi.ini
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    [uwsgi]
    chdir=/Users/jero/dev/thm_env/THM
    module=wsgi:application
    pp=/Users/jero/dev/thm_env
    master=True
    pidfile=/tmp/uwsgi-thm.pid
    socket=127.0.0.1:8083
    processes=1
    limit-as=128
    vacuum=True
    max-requests=5000
    home=/Users/jero/dev/thm_env
    debug=True
    need-app=True
    single-interpreter=True
    touch-reload=/Users/jero/dev/thm_env/THM
    13 changes: 13 additions & 0 deletions wsgi.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    import sys
    import os
    from django.core.handlers.wsgi import WSGIHandler

    # If using virtualenvs
    import site
    envpath = "/Users/jero/dev/thm_env/lib/python2.7/site-packages"
    site.addsitedir(envpath)

    sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'THM'))

    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    application = WSGIHandler()