I have reverse proxy nginx setup with the configuration.
upstream cluster {
least_conn;
server 192.168.4.137:8001;
server 192.168.4.137:8002;
}
server {
listen 8000;
server_name 192.168.4.137;
charset utf-8;
log_not_found on;
access_log logs/host.access.log main;
error_log logs/host.error.log;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/xml
text/css
text/comma-separated-values
text/javascript
application/javascript
application/x-javascript
application/atom+xml
application/json
application/x-json;
location ~ \.(jpg|jpeg)$ {
internal;
root D:\\;
}
location / {
proxy_pass http://192.168.4.137:8001;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 1800;
proxy_connect_timeout 60;
}
The location matcher for jpg /jpeg is internal redirect and can contain '%' in file names.
location ~ \.(jpg|jpeg)$ {
internal;
root D:\\;
}
The '%' is getting decoded and hence 404 is thrown for the wrong names.
I have already tried:
- using $request_uri in proxy pass
- using rewrite (.+)%20(.+) "$1%20$2" in the location block
UPDATE 1: In reponse to the rest call, response is the file path with redirect header:
url = "\\Negative\\alcohol%20negative (10).jpeg"
response['X-Accel-Redirect'] = url
Error log generate in nginx is :
2018/06/16 18:28:45 [error] 15328#2636: *10 CreateFile() "D:\\Negative\alcohol negative (10).jpeg" failed (2: The system cannot find the file specified), client: 192.168.4.137, server: 192.168.4.137, request: "GET /rest/image/imagedata?id=3341869 HTTP/1.1", upstream: "http://192.168.4.137:8001/rest/image/imagedata?id=3341869", host: "192.168.4.137:8000", referrer: "http://192.168.4.137:4200/detail/3341869"
None of the above two methods have worked so far.
Please suggest an alternative for the same.