Custom domain with NGINX reverse proxy

Last change on 2025-03-17 • Created on 2025-03-17 • ID: ST-D327F

Currently, it is not possible to assign a custom domain name to a Bucket. If you want to use your own domain, you can manually set up domain forwarding.

This how-to guide explains how to forward the domain via the NGINX reverse proxy on a Debian-based system.

Prerequisites:

  • Your own domain
  • A server with a public IP address
  • A Bucket with public objects

By the end of this how-to guide, the server should forward all requests directly to the Bucket.


  1. Create a new DNS entry

    Create a new DNS record. Point the domain at the IP address of the server on which you plan to set up the NGINX reverse proxy.

    Note that it can take several hours to propagate.


  1. Install NGINX

    Connect to the server and check if NGINX is already installed. If it isn't, install it now:

    sudo apt update && sudo apt install nginx -y
    nginx -v

  1. Create an NGINX configuration

    Create a new configuration file to set up the reverse proxy:

    sudo nano /etc/nginx/sites-available/bucket

    Paste one of the configurations below into the file.

    • Without SSL certificate:

      Replace example.com with your domain and <bucket_name>.<region> with the name and region of your Bucket.

      server {
          listen 80;
          server_name example.com;
      
          location / {
              proxy_pass https://<bucket_name>.<region>.your-objectstorage.com;
      
              proxy_set_header Host <bucket_name>.<region>.your-objectstorage.com;
              proxy_set_header X-Forwarded-Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
      }
    • With SSL certificate:

      Replace example.com with your domain and <bucket_name>.<region> with the name and region of your Bucket.
      Change the paths for ssl_certificate to point to your own certificate files.

      server {
          listen 80;
          server_name example.com;
      
          location / {
              return 301 https://$host$request_uri;
          }
      }
      
      server {
          listen 443 ssl;
          server_name example.com;
      
          ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
          ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
      
          location / {
              proxy_pass https://<bucket_name>.<region>.your-objectstorage.com;
      
              proxy_set_header Host <bucket_name>.<region>.your-objectstorage.com;
              proxy_set_header X-Forwarded-Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
      }

  1. Apply the changes

    sudo ln -s /etc/nginx/sites-available/bucket /etc/nginx/sites-enabled/bucket
    sudo rm /etc/nginx/sites-available/default && sudo rm /etc/nginx/sites-enabled/default
    sudo nginx -t
    sudo systemctl reload nginx

When you access your domain, the server should now forward the request to the Bucket.