mardi 18 décembre 2018

Nginx cache some location(static files) from another reverse proxy location

I have backend web-application working on 8081 port. It is Java spring boot application like uber-jar. So, static files placed into jar file. I have nginx as frontend. And I want to setting up cache static files on frontend. I thought what it is something like this:

proxy_cache_path /tmp levels=1:2 keys_zone=my_cache:10m max_size=10g
             inactive=60m use_temp_path=off;

server {
listen 80; 
server_name site.ru;

location /my_app {
    proxy_pass         http://127.0.0.1:8081;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   Host $http_host;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
}   

location ~ /my_app/.+\.css {
    proxy_pass http://127.0.0.1:8081;
    proxy_cache            my_cache;
    proxy_cache_valid      200  1d; 
}   

}

... but it is not working. I believe what I on right way, though a little bit wrong

Aucun commentaire:

Enregistrer un commentaire