Answer the question
In order to leave comments, you need to log in
How to correctly register a redirect with regular expressions and proxy_pass through NGINX ??
They suggested that in order to receive data from another domain, with a cors error, you can use proxying through NGINX using the proxy_pass
config:
location ~* ^.*\/proxy\/(?<pschema>.*)?\/(?<phost>.*)?\/.*$ {
set $adr $pschema://$phost;
rewrite ^.*\/proxy\/.*?\/.*?(\/.*)$ $1 break;
proxy_pass $adr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $phost;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
proxy_connect_timeout 1;
proxy_intercept_errors on;
expires 30;
break;
}
https://my.domain.ru/proxy/https/api.binance.com/api/v1/time
https://api.binance.com/api/v1/time
Answer the question
In order to leave comments, you need to log in
Correct like this:
location ~* ^/proxy/(?<pschema>https?)/(?<phost>[\w.]+)(?<puri>/.*) {
set $adr $pschema://$phost;
rewrite .* $puri break;
proxy_pass $adr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $phost;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
proxy_connect_timeout 1;
proxy_intercept_errors on;
expires 30;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question