---
# System prepended metadata

title: SSL configuration using nginx

---

# SSL configuration using nginx

First install `nginx` on the server
```
sudo apt update

sudo apt install nginx -y 
```

Enable and start the `nginx` service:

```
sudo systemctl enable nginx.service
   
sudo systemctl start nginx.service
```

Point the domain name to the IP address of the server from CloudFlare (if you have access to Cloudflare account or ask Piyush/OB to do this. I had to ask Piyush as I did not have access)

Now we create a `nginx` config file for our domain:
```
server {

    server_name subquery.goldberg.avail.tools;

    

    location / {
        proxy_pass http://subquery.goldberg.avail.tools:3000;
        proxy_set_header Host $host; # Add this line to preserve the original host header
    }

    location /ws {
        proxy_pass http://127.0.0.1:8888/ws;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 999999999;
    }

}

```

I'm using `subquery.goldberg.avail.tools` as an example, you can replace that with any domain that you have pointed to the server.

Save the file and create a symbolic link and restart `nginx` service:

```
sudo ln -s /etc/nginx/sites-available/subquery /etc/nginx/sites-enabled
    
sudo systemctl restart nginx.service
```

Install `certbot` for setting up SSL on the domain
```
sudo apt install certbot python3-certbot-nginx
 
sudo certbot --nginx -d subquery.goldberg.avail.tools

sudo systemctl restart nginx.service
```

You can now access the indexer at https://subquery.goldberg.avail.tools/