Skip to content

Disable caching when using a reverse proxy #467

Open
@ProphetLamb

Description

@ProphetLamb

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions