Nginx configuration for gunicorn


/ Published in: ActionScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # Simple Version
  2.  
  3. server {
  4. listen 80;
  5. server_name example.com;
  6. access_log /var/log/nginx/example.log;
  7.  
  8. location / {
  9. proxy_pass http://127.0.0.1:1337;
  10. }
  11. }
  12.  
  13. # Advanced version
  14.  
  15. worker_processes 1;
  16.  
  17. user nobody nogroup;
  18. pid /tmp/nginx.pid;
  19. error_log /tmp/nginx.error.log;
  20.  
  21. events {
  22. worker_connections 1024;
  23. accept_mutex off;
  24. }
  25.  
  26. http {
  27. include mime.types;
  28. default_type application/octet-stream;
  29. access_log /tmp/nginx.access.log combined;
  30. sendfile on;
  31.  
  32. upstream app_server {
  33. server unix:/tmp/gunicorn.sock fail_timeout=0;
  34. # For a TCP configuration:
  35. # server 192.168.0.7:8000 fail_timeout=0;
  36. }
  37.  
  38. server {
  39. listen 80 default;
  40. client_max_body_size 4G;
  41. server_name _;
  42.  
  43. keepalive_timeout 5;
  44.  
  45. # path for static files
  46. root /path/to/app/current/public;
  47.  
  48. location / {
  49. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  50. proxy_set_header Host $http_host;
  51. proxy_redirect off;
  52.  
  53. if (!-f $request_filename) {
  54. proxy_pass http://app_server;
  55. break;
  56. }
  57. }
  58.  
  59. error_page 500 502 503 504 /500.html;
  60. location = /500.html {
  61. root /path/to/app/current/public;
  62. }
  63. }
  64. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.