Skip to content

Instantly share code, notes, and snippets.

@j4mie
Created February 9, 2012 09:46
Show Gist options
  • Save j4mie/1778918 to your computer and use it in GitHub Desktop.
Save j4mie/1778918 to your computer and use it in GitHub Desktop.
# How to run Sentry in a subdirectory (http://your.server.com/sentry/) with nginx

How to run Sentry in a subdirectory with nginx

Scenario: you already have an app running at http://your.server.com/ and you want to run Sentry at http://your.server.com/sentry/

I spend a few hours banging my head against this, and finally got it to work. There may be a better way, but I couldn't find it.

Warning: hacky.

nginx.conf (in server stanza)

....

# if your main app's static media is served at _static, you're screwed
rewrite ^(/_static/)(.*)$ http://your.server.com/sentry/_static/$2 permanent;

location /sentry {
     rewrite /sentry/(.*) /$1 break;
     proxy_pass http://localhost:9000/sentry/;
     proxy_set_header Host $host;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

....

sentry.conf.py

....

SENTRY_URL_PREFIX = '/sentry'
FORCE_SCRIPT_NAME = '/sentry'

....

bonus: /etc/init/sentry.conf

description "start sentry"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

chdir /path/to/sentry
exec sudo -i -u yourusername /path/to/sentry/env/bin/sentry start --config=/path/to/sentry/sentry.conf.py --debug >> /tmp/sentry.log 2>&1
@egel
Copy link

egel commented Nov 15, 2019

I found this in official Sentry documentation https://docs.sentry.io/server/nginx/#hosting-sentry-at-a-subpath

Screenshot 2019-11-15 at 13 58 27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment