DEV Community

Cover image for Configuring NGINX configuration for Sentry self-hosted
Malek Hijazi
Malek Hijazi

Posted on • Originally published at on

Configuring NGINX configuration for Sentry self-hosted

This blog is the third post in the Sentry self-hosted series. You will set up the NGINX configuration for your Sentry self-hosted instance in this post. This post will assume you already went over the previous post that explains how to set up your custom subdomain to point to the server with Sentry self-hosted instance installed.

If you did everything correctly, your domain would still not be working as we need to tell NGINX how to redirect to the port Sentry is running on. To do so, you will need to set up the NGINX configuration.

There's an article on the DigitalOcean blog that explains this in detail. However, I will go through the needed steps to set it up.

First, you will need to ssh into the server.

The NGINX configuration directory is usually at /etc/nginx. Inside this directory, you will see a few directories/files. We will be using 2 of these directories.

  1. sites-available: This is where we will configure the available domains.
  2. sites-enabled: This is where we will configure the enabled domains.

Note: you can have many domains available but not enabled. If a domain is not enabled, it won't be publicly accessible.

We will be creating a new configuration file inside the sites-available directory. cd into the sites-available directory, and you should have a default file present in the directory. You can either copy this file into a new file using the below command:

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/

Enter fullscreen mode Exit fullscreen mode

PS: make sure to change the name of the second file from to the domain you used in the previous article.

Or you can copy the below code and modify the content:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
             # this will route to port 9000
            proxy_pass http://localhost:9000;

Enter fullscreen mode Exit fullscreen mode

Once you're done, save the file.

Now you have your site available, but it is not enabled yet.

We can create symbolic links from the file you just created to the sites-enabled directory, which Nginx reads from during startup.

To enable the domain, you will need to use the below command:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Enter fullscreen mode Exit fullscreen mode

PS: don't forget to change the to the one you used while setting up.

Your site is now enabled, though it won't be working just yet. There's one more step you need to do for it to work. We need to restart NGINX so that the configuration would be applied.

Restart NGINX with the below command:

sudo systemctl restart nginx

Enter fullscreen mode Exit fullscreen mode

After NGINX restarts, the domain should be working.

Good luck!

Top comments (0)