Sentry is a free and open-source application for error tracking. It can be used to monitor and fix errors in real-time. Sentry notifies you via email and SMS when errors occur or recur. It can integrate with a wide range of applications, including Bitbucket, GitHub, GitLab, Jira, Trello, Redmine, and more.
In this tutorial, we will learn how to set up Sentry with Docker on Ubuntu 22.04.
Requirements
- A cloud server running Ubuntu 22.04.
- A root password set on your server.
- Minimum two vCores and 10 GB of disk space.
Server Update
Before getting started, we recommend updating your packages to the latest version. You can update all your packages with the following command:
# apt-get update && apt-get upgrade -y
Once the system is updated, restart your server to apply all configuration changes.
Docker Installation
First, you'll need to add the Docker repository key:
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
And add the repository:
# add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable"
Next, install some packages required by Sentry. You can install them all with the following command:
# apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin nginx python3-certbot-nginx -y
Sentry Installation
First, create a Sentry user with the following command (with root user):
# adduser sentry && usermod -aG sudo sentry
Next, log in with the Sentry user and configure the Sentry repository with the following commands:
# su - sentry
# VERSION="24.3.0" && git clone https://github.com/getsentry/self-hosted.git && cd self-hosted && git checkout ${VERSION}
Next, run the Sentry installation script (it's coffee time):
# sudo ./install.sh
When the installation is complete, it will prompt you to create a user for Sentry (email and password). Then, modify the configuration file:
nano sentry/sentry.conf.py
To uncomment and modify the line (enter your Sentry registration):
CSRF_TRUSTED_ORIGINS = ["https://sentry.example.com", "http://127.0.0.1:9000"]
Finally, bring up the containers:
# sudo docker compose up -d && exit
NGINX Configuration
Once Sentry is installed, you can configure a Reverse Proxy with NGINX to use it over HTTPS. Create a site for this:
# nano /etc/nginx/sites-enabled/sentry
With the following content (replace server_name with the corresponding one):
server {
listen 80;
server_name sentry.example.com; # Change this to your registration
location / {
proxy_pass http://127.0.0.1:9000; # This line defines the destination address
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Once the file is created, restart nginx:
# systemctl restart nginx
Subsequently, acquire the certificate with certbot:
# certbot --nginx --redirect -d sentry.example.com
Sentry will now be installed and running on the HTTPS port! You just need to open your web browser and enter the URL: https://sentry.example.com and complete the configuration by logging in with the user created during the Sentry installation:
Remember, if you have any questions about this or any other issue related to your servers in Clouding, don't hesitate to write to soporte@clouding.io We're here for whatever you need, ask us!