Deploying Sentry with Nginx

Nginx provides a very powerful platform for running in front of Sentry as it gives us features like rate limiting.

If you’re on Ubuntu, you can simply install the nginx-full package which will include the required RealIP module. Otherwise you’ll need to compile Nginx from source with --with-http_realip_module.

For configuration instructions with regards to incoming mail via nginx see Inbound Email via Nginx.

Basic Configuration

Below is a sample production ready configuration for Nginx with Sentry:

http {
  # set REMOTE_ADDR from any internal proxies
  # see
  real_ip_header X-Forwarded-For;
  real_ip_recursive on;

  # SSL configuration -- change these certs to match yours
  ssl_certificate      /etc/ssl/;
  ssl_certificate_key  /etc/ssl/;

  # NOTE: These settings may not be the most-current recommended
  # defaults
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:128m;
  ssl_session_timeout 10m;

  server {
    listen   80;

    location / {
      if ($request_method = GET) {
        rewrite  ^ https://$host$request_uri? permanent;
      return 405;

  server {
    listen   443 ssl;

    proxy_set_header   Host                 $http_host;
    proxy_set_header   X-Forwarded-Proto    $scheme;
    proxy_set_header   X-Forwarded-For      $remote_addr;
    proxy_redirect     off;

    # keepalive + raven.js is a disaster
    keepalive_timeout 0;

    # use very aggressive timeouts
    proxy_read_timeout 5s;
    proxy_send_timeout 5s;
    send_timeout 5s;
    resolver_timeout 5s;
    client_body_timeout 5s;

    # buffer larger messages
    client_max_body_size 5m;
    client_body_buffer_size 100k;

    location / {
      proxy_pass        http://localhost:9000;

      add_header Strict-Transport-Security "max-age=31536000";

If you’re using SSL, you’ll also need to set the following in


Hosting Sentry at a Subpath

This method is unsupported and there is no proven way to accomplish this. Please use a dedicated domain or subdomain.