0

Sentry needs a value the location it is installed: SENTRY_URL_PREFIX. The problem is that I want to log errors to an installation via two different lan's.

Lets say, the server that's running sentry has an ip 192.168.1.1 and 10.0.0.1, and I want to log errors from 192.168.1.2 and from 10.0.0.2.

The connection between the sentry server (machine) and the machines that need to do the logging is fine, but I need to 'switch' a url-prefix setting in sentry for it to work with one or the other: If I set the SENTRY_URL_PREFIX to http://10.0.0.1 it works and is able to receive logs from that lan, but all requests from the other lan go wrong (direct http request for the frontend get an http 400 result for instance) and of course the other way around.

Details: I'm running sentry 8.1.2 in docker (https://hub.docker.com/_/sentry/)

Interestingly enough, I read this in the changelog

SENTRY_URL_PREFIX has been deprecated, and moved to system.url-prefix inside of config.yml or it can be configured at runtime.

Starting sentry for the first time actually still seems to ask for the prefix; changing the prefix does seem to work for the connections, so to me it looks like this is the culprint. It could be that behind the scenes this is communicated to above mentioned system.url-prefix, so that this setting is the problem, but I'm not sure.

Does anyone know how to run one server on two adresses? The main issue is of course sending the errors, it's not a big deal to have the web-interface only visible from one ip.

Nanne
  • 64,065
  • 16
  • 119
  • 163

1 Answers1

0

While I'm not really sure how it is supposed to work, I could not get any logs to a server with a different system.url-prefix then I used in the call.

From twitter and the sentry group I gather that it does need the correct host for the interface, while it shouldn't really break stuff otherwise. Not sure how to unbreak it though.

The solution for me was just to address the sentry install from one point. Because we need the separate NIC's, we do this by using a simple nginx reverse proxy in front of the set-up, and let that set the host header. I used a default https://hub.docker.com/_/nginx/ image, and this config:

events {
  worker_connections  1024;  ## Default: 1024
}

http{
    server {
        listen       80;

        location / {
           proxy_pass                        http://$internalip-sentry-knows;
           proxy_redirect                    http://$internalip-sentry-knows $externalip-we-use;
           proxy_set_header  Host            $internalip-sentry-knows;
           proxy_set_header  X-Real-IP       $remote_addr ;
           proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
       }
    }
}

The port is exposed to both nics, so this listens to both adresses we want to use, and proxys it nice and easy to sentry.

Disclaimer: The interface speaks of SENTRY_URL_PREFIX but that's deprecated, so I use system.url-prefix, but for all practical purposes in my answer they are interchangeable. This could be a source of confusion for someone who does know what goes where exactly :)

References:
* twitter conversation with Matt from sentry
* Groups response from David from sentry

Nanne
  • 64,065
  • 16
  • 119
  • 163