Nginx Proxy for s3 compatible storage & buckets

people

Lets Try

. 1 min read

Nginx can be used as a reverse proxy for S3 compatible storage and buckets. This is useful in many scenarios, including adding authentication, security or custom routing to S3-compatible solutions. The following steps will show you how to configure Nginx for S3 compatible storage.

Installing Nginx

Install Nginx if you haven't done so already. Your operating system will determine the specific method of installation. On a Debian system, for example, you can:

sudo apt-get update
sudo apt-get install nginx

Configure Nginx:

Create a new Nginx configuration file or modify an existing one in the /etc/nginx/sites-available/ directory. For example, you can create a file named yourdomain.com:

sudo nano /etc/nginx/sites-available/yourdomain.com

Here's a basic configuration example:

server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://s3-compatible-storage-endpoint;
    }
}

Replace yourdomain.com with your actual domain or server IP address, and http://s3-compatible-storage-endpoint with the actual URL of your S3-compatible storage provider (e.g., Digitalocean spaces, MinIO, Wasabi, or your self-hosted S3-compatible service). example of Digitalocean space url : https://bucket.sgp1.cdn.digitaloceanspaces.com/ .

Activate the Configuration:

Create a symbolic link to enable the site configuration:

sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/

Test and Reload Nginx:

Before you reload Nginx, it's a good practice to test the configuration for syntax errors:

sudo nginx -t
sudo systemctl reload nginx

If there are no errors, you can reload Nginx to apply the new configuration:

Configure the DNS using Cloudflare

Verify that the DNS records are pointing to the Nginx server, using the name of the domain specified in the Nginx Configuration. With Cloudflare Proxy on you will get https connection.

Access your S3 compatible storage

Now you can access S3 compatible storage via your Nginx proxy. For example, if you set up your proxy for yourdomain.com, you can access your S3-compatible storage at http://yourdomain.com.

This is only a very basic configuration. You may have to make additional settings to optimize and secure your setup, depending on what you need. These include SSL/TLS and authentication. Also, follow the best practices to secure your Nginx Server and S3 compatible storage.

Try S3 buckets free for 60 days

  1. DigitalOcean.com - Get $100 Credit Free for 60 days
  2. vultr.com - Get $100 Credit Free




More Stories from

Lets Try
Lets Try.1 min read

Deploy Tailscale in Portainer docker container Raspberry pi

A comprehensive guide on deploying Tailscale through Portainer in Raspberry pi. lets integrate Tailscale into your existing Docker setup.

Lets Try
Lets Try.1 min read

How to disable only_full_group_by from server sql-mode Permanently

2 ways to Remove ONLY_FULL_GROUP_BY in mysql server Temporary & Permanently. with phpmyadmin and by modifying the server configuration file

.
Dev
Dev.2 min read

Window Server 2025 Contabo VPS Install Guide

Window server in contabo is very costly but you can deploy your license key with custom image.

Dev
Dev.1 min read

Setting up SSH keys to a Ubuntu Server with Mac

Generating SSH keys on a Mac for use with an Ubuntu server is a straightforward process. Here’s a step-by-step guide: Generate the SSH Key Pair

.
Dev
Dev.1 min read

Git/Github Clone Private Repository on Ubuntu Server 24.04

GitHub is a free platform that provides repository hosting and We will guide you to install Git on Ubuntu 24.04, adding and cloning a repository from GitHub to your Ubuntu VPS server.

.
Built on Koows