Experiencing a 502 HTTP Error on Fresh Sentry Install

I’ve been trying to install Sentry on my VPS for the past couple of hours, however, regardless of which guide or documentation I follow, I seem to experience a 502 Error which I can’t seem to fix.

Note, this is my first time attempting to use Docker. So troubleshooting was that much more difficult.

I got my VPS from DigitalOcean, deployed their Docker Droplet.

From there, I cloned the Sentry On-Premise github repo and proceeded with the installation using ./install.sh. The installation itself went pretty smooth.

After the installation I used docker-compose up -d to start the instance.
By this point, checking docker-compose ps seemed to show everything working smoothly

root@services:~/onpremise# docker-compose ps
WARNING: The SENTRY_IMAGE variable is not set. Defaulting to a blank string.
        Name                       Command               State           Ports         
---------------------------------------------------------------------------------------
onpremise_cron_1        /entrypoint.sh run cron          Up      9000/tcp              
onpremise_memcached_1   docker-entrypoint.sh memcached   Up      11211/tcp             
onpremise_postgres_1    docker-entrypoint.sh postgres    Up      5432/tcp              
onpremise_redis_1       docker-entrypoint.sh redis ...   Up      6379/tcp              
onpremise_smtp_1        docker-entrypoint.sh exim  ...   Up      25/tcp                
onpremise_web_1         /entrypoint.sh run web           Up      0.0.0.0:9000->9000/tcp
onpremise_worker_1      /entrypoint.sh run worker        Up      9000/tcp         

Once this was done, I proceeded with installing and setting up nginx. (which I am a little more familiar with).

My Nginx configuration is as follows:

server {
   listen 80 default_server;
   server_name sentry.domain.com;
   location / {
       proxy_pass         http: / /localhost :9000;   # Had to change this to avoid link restriction
       proxy_redirect     off;
       proxy_set_header   Host              $host;
       proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
       proxy_set_header   X-Forwarded-Proto $scheme;
   }
}

So far so good. Visiting sentry.domain.com redirects to sentry[.]domain[.]com/auth/login. BUT, it shows a 502 Bad Gateway error.

I checked the nginx error log which shows the following:

2019/09/17 12:09:50 [error] 19673#19673: *3 upstream prematurely closed connection while reading response header from upstream, client: the_ip_address, server: sentry. domain .com, request: "GET /auth/login/ HTTP/1.1", upstream: "http:// 127.0 .0 . 1 :9000/auth/login/", host: "sentry. domain .com"
2019/09/17 12:10:33 [error] 19673#19673: *5 upstream prematurely closed connection while reading response header from upstream, client: the_ip_address, server: sentry. domain .com, request: "GET /auth/login/ HTTP/1.1", upstream: "http:// 127.0 . 0.1 :9000/auth/login/", host: "the_ip_address"

I also checked the access logs which shows the following:

121.58.252.222 - - [17/Sep/2019:12:10:45 +0000] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
121.58.252.222 - - [17/Sep/2019:12:10:46 +0000] "GET /auth/login/ HTTP/1.1" 502 584 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"

Lastly I checked the docker logs via docker-compose logs

web_1        | 172.19.0.1 - - [17/Sep/2019:12:13:22 +0000] "GET /auth/login/ HTTP/1.0" 500 0 "-" "insomnia/6.6.2"
web_1        | 172.19.0.1 - - [17/Sep/2019:12:22:02 +0000] "GET / HTTP/1.0" 302 467 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"

What was interesting about this was the 500 error. However, no search on Google was able to help me figure out how to troubleshoot that further.

So after several hours of trying to figure out how to proceed further, I am finally on this thread, hoping someone would help me figure this out. I really appreciate any help.

Suggest you to review your Nginx set up.

Here is my install


I have a Nginx container as the entry point. From external, https access using port 447 and http access using port 446. These two ports are mapped to 8080 and 80 by docker and sent to Nginx, who later send to the sentry web container instead of “localhost”

I can not see your Nginx container, but I guess your Nginx setting is of “http://localhost:9000”, which means that on the same docker container you have both nginx service and sentry web service? Maybe this is the problem.

@uziiuzair if you are doing it for the first time and it is your first experience with docker then why are you using it with docker and conventional digitalOcean.
You see it could be a very tough job to manage cloud hosting. Big companies often higher a full time sys-sdmin just to manage the cloud hosting.
Here, you may have opted for the third party host as their are companies like cloudways who are providing the managed version of digitalOcean web server by taking away all the hassles of server management.