0

I have django website and remote image storage. I want to proxy for example /images/ from django to server 10.0.0.40/images/.

location /images/ {
    proxy_pass http://10.0.0.40/images/;
}

No errors in nginx. But django returns Page not found should I set something in urls.py or configuration is not so simple? And will it work in Chrome browser at all? Because https -> http doesn't work in Chrome.

Expected:

test.com/images/test.jpg -> http://10.0.0.40/images/test.jpg

Victoria
  • 1
  • 1
  • Try: `location ^~ /images/` – Richard Smith Mar 12 '21 at 07:45
  • Can you configure your application to return accurate image links rather than proxy images? Proxying you pay for bandwidth twice, remote server to your server, then your server to the client. – Tim Mar 12 '21 at 07:54
  • I can simply set normal url to image, but it will be request from https to http and Chrome automatically updates http to https, so it doesn't work. – Victoria Mar 12 '21 at 08:09

1 Answers1

0

Try search manuals with the following request: "nginx how to set up reverse proxy with https" (or something like that). It gives you many manuals how to proxy a HTTPS connection to a HTTP server. (Including the information about proxy_set_header X-Forwarded-Proto $scheme; that you missed, I suppose.)

Bonus:

NGINX proxy_pass's documentation:

A request URI is passed to the server as follows:

If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive:

        location /name/ {
            proxy_pass http://127.0.0.1/remote/;
        }

If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI:

        location /some/path/ {
            proxy_pass http://127.0.0.1;
        }

In your case, using this you can rewrite your directive as the following: proxy_pass http://10.0.0.40;

Nick Vee
  • 101
  • 3