T
T
Taras Labiak2020-08-21 17:24:38
Nginx
Taras Labiak, 2020-08-21 17:24:38

Is it possible to perform a hidden browser redirect in nginx?

There is a backend that redirects from a permanent URL to a temporary signed URL on AWS S3. We need a proxy server that for Firefox and Safari (you can determine by the user-agent header) would carry out this redirect (that is, not in the browser, on the proxy server) and transmit the response from AWS S3. Those. for Firefox or Safari, the URL will not change, and the proxy server will send them a response from AWS S3. Other browsers don't need this because downloading directly from AWS S3 is faster. Is it possible to use nginx for this?
In extreme cases, such a proxy server can be quickly written on node.js, but it seems to me that a solution with nginx will be more reliable

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kocherman, 2020-08-21
@kocherman

Can

server {
      access_log  logs/access.log;
      error_log   logs/error.log;
      index       index.html;
      listen      202.54.1.5:80 default;
      root        /usr/local/nginx/html;
      server_name example.com www.example.com 0.example.com;
 
 
     ## PROXY - Web
      location / {
        proxy_pass  http://myproxybackend;
        if ($http_user_agent ~ MSIE ) {
              proxy_pass  http://msiebackend;
        }
        if ($http_user_agent ~ Mozilla ) {
              proxy_pass  http://mozillabackend;
        }
 
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
 
        ...
         ..
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question