nginx.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Configuring Sentry with Nginx
  2. =============================
  3. Nginx provides a very powerful platform for running in front of Sentry as it
  4. gives us features like rate limiting.
  5. Below is a sample configuration for Nginx which includes (reasonable) rate
  6. limits:
  7. ::
  8. http {
  9. # we limit both on IP (single machine) as well as project ID
  10. limit_req_zone $binary_remote_addr zone=one:10m rate=3r/s;
  11. limit_req_zone $projectid zone=two:10m rate=3r/s;
  12. # limit_req_status requires nginx 1.3.15 or newer
  13. limit_req_status 429;
  14. server {
  15. listen 80;
  16. proxy_set_header Host $http_host;
  17. proxy_set_header X-Real-IP $remote_addr;
  18. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  19. proxy_set_header X-Forwarded-Proto $scheme;
  20. proxy_redirect off;
  21. location / {
  22. proxy_pass http://localhost:9000;
  23. }
  24. location ~* /api/(?P<projectid>\d+/)?store/ {
  25. proxy_pass http://localhost:9000;
  26. limit_req zone=one burst=3 nodelay;
  27. limit_req zone=two burst=10 nodelay;
  28. }
  29. }
  30. }
  31. Proxying uWSGI
  32. ~~~~~~~~~~~~~~
  33. You may optionally want to setup `uWSGI <http://projects.unbit.it/uwsgi/>`_ to
  34. run Sentry (rather than relying on the built-in gunicorn webserver).
  35. Within your uWSGI configuration, you'll need to export your configuration path
  36. as well the ``sentry.wsgi`` module:
  37. ::
  38. [uwsgi]
  39. env = SENTRY_CONF=/etc/sentry.conf
  40. module = sentry.wsgi
  41. ; spawn the master and 4 processes
  42. http-socket = :9000
  43. master = true
  44. processes = 4
  45. ; allow longer headers for raven.js if applicable
  46. ; default: 4096
  47. buffer-size = 32768