Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable caching when using a reverse proxy #467

Open
ProphetLamb opened this issue Feb 25, 2024 · 0 comments
Open

Disable caching when using a reverse proxy #467

ProphetLamb opened this issue Feb 25, 2024 · 0 comments

Comments

@ProphetLamb
Copy link

ProphetLamb commented Feb 25, 2024

Generate a general.conf without media caching for reverse proxy consumption.

Information

The routing does not pass through the proxy when location handling for media caching is present in the general.conf, instead nginx attempts to route these requests via the default site.
The directory of the default site - in my case - is empty. It doesn't contain the css or js resources the web app at the proxy_pass offers.
It is not desired and not reasonable to cache a proxy location by default.

Details

Description

This is caused by the location handling in general.conf included in every reverse proxy domain.

# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
    expires 7d;
}

# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
    add_header Access-Control-Allow-Origin "*";
    expires    7d;
}

Steps to reproduce

  1. Create a basic node application and serve at localhost:3000.
  2. Create a NGINX Config with a proxy pass from the subdomain app.example.com to localhost:3000.
  3. Open your browser devtools network tab
  4. Request app.example.com in your browser
  5. Media types handled in general.conf will fail with 404.

Expected behavior

Resources are requested from the reverse proxy

Screenshots

example

-  - [25/Feb/2024:19:51:08 +0000] "GET /_app/immutable/chunks/entry.aDhfE7Nt.js HTTP/2.0" 404 548 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
-  - [25/Feb/2024:19:51:08 +0000] "GET /_app/immutable/chunks/index.CA4DBg1v.js HTTP/2.0" 404 548 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant