How to proxy according to parameters in nginx

assume that nginx is on the a.com server

return the content after http://b.com/a.mp4 agent when you want to access http://a.com?URL=http://b.com/a.mp4

how should the configuration file be written

location ~* ^/_proxy/(.*)$ {
    proxy_pass $1;
}

neither

Jun.18,2022

can be forwarded via http://a.com?URL=http://b.com/a.mp4 and http://a.com/_proxy/http://b.com/a.mp4

location / {
    -sharp  http url 302
    if ( $request_uri ~ "(/|=)(http.*)" ) {
        rewrite ^(.*)$ http://$host/_proxy$1 break;
    }
}
    
location ~* ^/_proxy/ {

    -sharp  URL  DNS
    resolver 114.114.114.114;
       
    if ( $request_uri ~ "(/|=)(http.*)" ) {
        set $proxy_url $2;
    }  
    
    -sharp  host
    set $proxy_host $host; 
    if ( $proxy_url ~ "https?://(.*?)/" ) {
        set $proxy_host $1;
    }   
    
    proxy_set_header Host $proxy_host;
    proxy_set_header X-Forwarded-For $remote_addr;

    proxy_pass $proxy_url;
}
Menu