Advertisement
furas

Nginx - Gunicorn

Nov 9th, 2016
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 0.96 KB | None | 0 0
  1. #file: /var/nginx/sites-available/wsgi-test
  2. #link: /var/nginx/sites-enabled/wsgi-test
  3.  
  4. server {
  5.     listen 80;
  6.  
  7.     # access by name
  8.     server_name wsgi; # on localhost I use shortname `wsgi` so I have in /etc/hosts: "127.0.0.1 wsgi"
  9.     server_name subdomain.example.com;
  10.  
  11.     # static files
  12.     root /var/www/wsgi-test;    
  13.     index index.html index.htm;
  14.  
  15.     # logs
  16.     access_log /var/log/nginx/wsgi-access.log;
  17.     error_log /var/log/nginx/wsgi-error.log;
  18.  
  19.     # first try static files, later use Gunicorn
  20.     location / {
  21.         try_files $uri $uri/ @gunicorn;
  22.     }
  23.  
  24.     # connection to Gunicorn on localhost on port 3001
  25.     location @gunicorn {
  26.         proxy_pass http://127.0.0.1:3001;
  27.         include proxy_params;
  28.     }
  29. }
  30.  
  31. #file: /etc/nginx/proxy_params
  32.  
  33. proxy_set_header Host $http_host;
  34. proxy_set_header X-Real-IP $remote_addr;
  35. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  36. proxy_set_header X-Forwarded-Proto $scheme;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement