skip to Main Content

I have the following reverse proxy in Nginx. I am trying to hide the sig key.

location /documents {
    set $delimeter "";

    if ($is_args) {
       set $delimeter "&";
    }

    set $args "$args${delimeter}sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxTaaaaaaaaaaaaaaaaaaaaaaaaaaNgU%3D";

    proxy_pass https://testtestsitweu.blob.core.windows.net/publicfiles/MyFiles/;
    proxy_ssl_name testtestsitweu.blob.core.windows.net;
    proxy_ssl_server_name on;
}

But when I try to access it trough http://localhost:4200/documents/file.pdf I get the following error:

<?xml version="1.0" encoding="utf-8"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.
RequestId:8f693c6f-c01e-0000-65c7-647dca000000
Time:2024-02-21T13:11:22.3869564Z</Message></Error>

Normally I can access the file from https://testtestsitweu.blob.core.windows.net/publicfiles/MyFiles/file.pdf?sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxTaaaaaaaaaaaaaaaaaaaaaaaaaaNgU%3D

What I am doing wrong here?

2

Answers


  1. Chosen as BEST ANSWER

    Remove the "/" character from the end of the line where proxy_pass is located.

    location /documents {
        set $delimeter "";
    
        if ($is_args) {
           set $delimeter "&";
        }
    
        set $args "$args${delimeter}sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxTaaaaaaaaaaaaaaaaaaaaaaaaaaNgU%3D";
    
        proxy_pass https://testtestsitweu.blob.core.windows.net/publicfiles/MyFiles/;
        proxy_ssl_name testtestsitweu.blob.core.windows.net;
        proxy_ssl_server_name on;
    }
    

  2. try this code instead,

    location /documents {
    set $delimeter "";
    
    if ($is_args) {
       set $delimeter "%26";
    }
    
    set $args "$args${delimeter}sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxTaaaaaaaaaaaaaaaaaaaaaaaaaaNgU%3D";
    
    proxy_pass https://testtestsitweu.blob.core.windows.net/publicfiles/MyFiles/;
    proxy_ssl_name testtestsitweu.blob.core.windows.net;
    proxy_ssl_server_name on;
    }
    

    this may be because of how Nginx handles URL encoding. In your configuration, when you set the $args variable, the & character needs to be URL-encoded as %26 to ensure it’s properly interpreted as part of the query string. otherwise, it may be interpreted as a separator within the configuration.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search