Guest User

Untitled

a guest
Dec 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. from django.conf.urls import include, url, handler404, handler500
  2. from .views import error_404, error_500 -- into views was that {
  3.  
  4. from django.shortcuts import render
  5. def error_404(request):
  6. return render(request,'error_404.html')
  7. def error_500(request):
  8. return render(request,'error_500.html')
  9. }
  10. also in urls.py was this:
  11. handler404 = error_404
  12. handler500 = error_500
  13.  
  14. upstream theband {
  15. # fail_timeout=0 means we always retry an upstream even if it failed
  16. # to return a good HTTP response (in case the Unicorn master nukes a
  17. # single worker for timing out).
  18.  
  19. server unix:/webapps/theband/run/gunicorn.sock fail_timeout=0;
  20. }
  21.  
  22. server {
  23.  
  24. listen 80;
  25. server_name 207.154.232.99;
  26. client_max_body_size 4G;
  27.  
  28. access_log /webapps/theband/logs/nginx-access.log;
  29. error_log /webapps/theband/logs/nginx-error.log;
  30.  
  31. location /static/ {
  32. alias /webapps/theband/static/;
  33. }
  34.  
  35. location /media/ {
  36. alias /webapps/theband/media/;
  37. }
  38. location / {
  39. # an HTTP header important enough to have its own Wikipedia entry:
  40. # http://en.wikipedia.org/wiki/X-Forwarded-For
  41. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  42.  
  43. # enable this if and only if you use HTTPS, this helps Rack
  44. # set the proper protocol for doing redirects:
  45. # proxy_set_header X-Forwarded-Proto https;
  46.  
  47. # pass the Host: header from the client right along so redirects
  48. # can be set properly within the Rack application
  49. proxy_set_header Host $http_host;
  50.  
  51. # we don't want nginx trying to do something clever with
  52. # redirects, we set the Host: header above already.
  53. proxy_redirect off;
  54.  
  55. # set "proxy_buffering off" *only* for Rainbows! when doing
  56. # Comet/long-poll stuff. It's also safe to set if you're
  57. # using only serving fast clients with Unicorn + nginx.
  58. # Otherwise you _want_ nginx to buffer responses to slow
  59. # clients, really.
  60. # proxy_buffering off;
  61. # we don't want nginx trying to do something clever with
  62. # redirects, we set the Host: header above already.
  63. proxy_redirect off;
  64.  
  65. # set "proxy_buffering off" *only* for Rainbows! when doing
  66. # Comet/long-poll stuff. It's also safe to set if you're
  67. # using only serving fast clients with Unicorn + nginx.
  68. # Otherwise you _want_ nginx to buffer responses to slow
  69. # clients, really.
  70. # proxy_buffering off;
  71.  
  72. # Try to serve static files from nginx, no point in making an
  73. # *application* server like Unicorn/Rainbows! serve static files.
  74. if (!-f $request_filename) {
  75. proxy_pass http://theband;
  76. break;
  77. }
  78. }
  79. error_page 404 /error_404.html;
  80. location = /error_404.html {
  81. root /webapps/theband/src/templates;
  82. }
  83.  
  84. # Error pages
  85. error_page 500 502 503 504 /error_500.html;
  86. location = /error_500.html {
  87. root /webapps/theband/src/templates;
  88. }
  89. }
Add Comment
Please, Sign In to add comment