0

I would like to have an api like this:

my-proxy-server.com/http://example.com/foo.pdf

that streams a response from http://example.com/foo.pdf. Note in this case http://example.com/foo.pdf is just an example, this could be any pdf url.

So in nginx.conf sudo code:

    location ~* ^/(?<urlpath>.*)$ {
      proxy_pass $urlpath;
    }

Is this possible with nginx + some other plugin? Looking for some pointers on implementing this.

1 Answers1

1

It is covered here. Essentially you will just use proxy_pass, e.g.:

location ~* ^/(?<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;
}
Danila Vershinin
  • 5,286
  • 5
  • 17
  • 21