---
title: "nginx With Wasabi: Setting Up nginx to Proxy Authentication Requests"
slug: "setting-up-nginx-to-proxy-authentication-requests-to-wasabi"
updated: 2024-06-20T15:20:53Z
published: 2024-06-20T15:20:53Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wasabi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# nginx With Wasabi: Setting Up nginx to Proxy Authentication Requests to Wasabi

The information in this article has been tested on a VM running on Ubuntu 22.04.4 LTS OS with nginx 1.21.6.

1. Update the packages on the system to make sure the system is up-to-date:

```plaintext
# sudo apt-get update 
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-IF6U41GM.png)
2. Once done, install the dependencies, which are essential, using the following command:

```plaintext
# sudo apt-get install build-essential libpcre3-dev zlib1g-dev libssl-dev -y 
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-BNQUT3IL.png)
3. The subsequent steps involve installing nginx from the source with the ngx_aws_auth and ssl modules. You can find the ngx_aws_auth module here:

```plaintext
https://github.com/anomalizer/ngx_aws_auth.git 
```
4. Since you need to install nginx with custom modules, download and extract nginx from the source using the following commands:

```plaintext
# wget http://nginx.org/download/nginx-1.21.6.tar.gz 

# tar -zxvf nginx-1.21.6.tar.gz
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-37PLF6Z4.png)
5. Navigate to the nginx folder and clone the GitHub repository containing the ngx_aws_auth module:

```plaintext
# cd nginx-1.21.6 

# git clone https://github.com/anomalizer/ngx_aws_auth.git 
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-QM71U0RG.png)

Wasabi recommends using the latest version of the module that supports AWS Signature v4.
6. Compile with the ngx_aws_auth (to proxy the requests to Wasabi) and ngx_http_ssl_module (for SSL support) modules and install it:

```plaintext
# ./configure --add-module=./ngx_aws_auth –with-http_ssl_moduleec 
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-K6YD73HQ.png)
7. Confirm that the ngx_aws_auth module was added:

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-CRAR8RP5.png)

```plaintext
# make
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-PI8IVGR1.png)

```plaintext
# sudo make install
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-KGLF5FNC.png)
8. Once done, modify the nginx conf file (located at /usr/local/nginx/conf/nginx.conf) using your preferred text editor to proxy authenticated requests to Wasabi. An example of a nginx conf server block is:

```plaintext
server { 

        listen       80; 

        server_name  localhost; 

        aws_access_key ED95YWC1NPCZ5HW5LF9A; 

        aws_key_scope 20240410/us-east-1/s3/aws4_request; 

        aws_signing_key EfIqSBXp2/wzALdsUeSpuB9lW5zaSCF68OOYHZL8gW4=; 

        aws_s3_bucket wasabi-nginx-test-bucket;  

        location / { 

            aws_sign; 

            aws_endpoint "s3.wasabisys.com";  

            proxy_pass https://wasabi-nginx-test-bucket.s3.wasabisys.com;  

            root   html; 

            index  index.html index.htm; 

        } 

         location = /50x.html { 

            root   html; 

        } 

 } 
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-KJM129DX.png)

aws_access_key will be the access key that you generate from the Wasabi Console [Access Keys feature](https://docs.wasabi.com/docs/access-keys-1).
9. Use the following command in the nginx-1.21.6/ngx_aws_auth folder to generate the aws_key_scope and aws_signing_key:

```plaintext
# python3 generate_signing_key -k XXXXXXXXXX -r us-east-1
```

or simply:

```plaintext
# ./generate_signing_key -k XXXXXXXXXX -r us-east-1
```

where XXXXXXXXXX is the AWS secret key associated with your AWS access key. us-east-1 is your bucket region.

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-3QKMX12V.png)

Use the first line of the output in the aws_signing_key section and use the second line in the aws_key_scope section.

Furthermore, replace wasabi-nginx-test-bucket with the name of your bucket, aws_endpoint with the appropriate endpoint depending on your bucket location, and proxy_pass with a URL in the following format: https://your-bucket-name-here.s3.your-wasabi-region-here.wasabisys.com
10. Start nginx:

```plaintext
# sudo /usr/local/nginx/sbin/nginx 
```

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-B7ROL750.png)
11. After starting nginx, you may test the working of the proxy using curl:

```plaintext
# curl http://localhost/text.txt; echo
```

Wasabi Test

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-R8TM29KW.png)

You will be trying to access the text.txt object under your respective bucket.

You can view the access logs using the following command:

```plaintext
# tail -f /usr/local/nginx/logs/access.log 

127.0.0.1 - - [12/Apr/2024:14:17:00 +0000] "GET /test.txt HTTP/1.1" 404 293 "-" "curl/7.81.0" 

127.0.0.1 - - [12/Apr/2024:14:17:12 +0000] "GET /text.txt HTTP/1.1" 200 11 "-" "curl/7.81.0" 
```

If your request yields a 404 error, you queried to the wrong object, one which does not exist in your bucket.

![](https://cdn.document360.io/bef0a1ea-7768-4d5a-b520-c4fe2f7fafad/Images/Documentation/image-VBDTM3BC.png)

You can enable logging on your bucket from the Wasabi Console [Bucket Settings feature](https://docs.wasabi.com/docs/bucket-management), which will generate access logs relevant to these requests. For example:

E94A502930FD68059CCAAD65BDEC94E539B48D67BD07C820AB64573A2EB2A592 wasabi-nginx-test-bucket [12/Apr/2024:14:33:51 +0000] 52.72.187.166 E94A502930FD68059CCAAD65BDEC94E539B48D67BD07C820AB64573A2EB2A592 7A916E8DF599C503:B REST.GET.OBJECT text.txt "GET /text.txt" 200 - 11 11 10 10 "" "curl/7.81.0" -
