Proxy_pass and assets issue

I have a website with a page with a reverse proxy.

I created 2 files under the appropriate domain inside nginx-includes

proxy.conf.j2

location /property-search/ {
   proxy_pass https://xxxxxxx.com/;
}

cache.conf.j2 (I use this for all my projects)

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
  expires 1M;
  access_log off;
  add_header Cache-Control "public";
  gzip_vary on;
}

# CSS and Javascript
location ~* \.(?:css|js)$ {
  expires 1y;
  access_log off;
  add_header Cache-Control "immutable";
  add_header Cache-Control "public";
  gzip_vary on;
}

but for some reason, it doesn’t load js/css/fonts on that page, but everything is ok on the other pages.

I think that the main reason is that Cross-domain CORS policy prevents assets from loading :frowning:

I tried to play around with the order of these rules because I thought that the problem was that the proxy_pass rule should come before the leverage browser caching of static assets rule, but no luck.

any idea or suggestion would be great because I am not an Nginx expert (but I am learning)

all good now, the problem was this rule

it works ok now with

location ^~ /property-search {
  proxy_pass https://xxxxxxx.com/;
}
2 Likes

This topic was automatically closed after 42 days. New replies are no longer allowed.