nginx:1.21.5 docker container.
there is two similar (as I think) configs:
server {
...
set $target_token "http://token-container:80";
location /token/ {
proxy_pass $target_token/;
expires -1;
proxy_read_timeout 60;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
and
server {
...
location /token/ {
proxy_pass http://token-container:80/;
expires -1;
proxy_read_timeout 60;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
First one has problems with cashing. (loaded page is blank. js didnt loaded)
Please look at the picture: (all items sizes are the same)
And the same page with the second config:
Why the usage of the variable spoil the page caching behavior?
Variable in the proxy_pass force you to handle URI too, otherwise it will be dropped. Something like this proxy_pass $upstream/api/$1$is_args$args;
I got it from: External resource: dev.to. Author: Daniel Albuschat
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.