• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue nginx proxypass not working for static files

becker.enterprises

New Pleskian
Server operating system version
Ubuntu 18.04
Plesk version and microupdate number
18.0.50
I try to load some files via an external server, so I added proxypass directives to the configuration of my domain.
This does work fine for non static files but with static files, nginx always tries to serve them which results in a 404.
I disabled serving of static files and intelligent serving too. Proxymode is the only thing I left checked.

How can I tell nginx to not serve any static files?
Here is a screenshot of my configuration:

2023-03-06_171612.png
 
@becker.enterprises

On the one hand, your location config is to strict with : location /cdn/

I cannot verify it, but that location directive should never get the desired result - Nginx will not associate (any or many) requests to that location, so whatever is included in the location directive will not be used : it is to some extent "dead" config.

On the other hand, you should try to use the return directive (as opposed to the proxy_pass).

The return directive can be more efficient and practical, unless you have the goal to cache specific requests on the local server - you probably will not have that goal, since otherwise the usage of a CDN would be rather contradictory.

In short, please try to

1 - fine-tune the location directive config
2 - use the return directive

and also try to consider to make your Nginx config a bit more elaborate - explicit config (read: more lines of config variables) is always better with Nginx.

Kind regards....
 
Thanks for your reply.

The return directive will not work in this case, because the server is an internal Thumbor Server which is not accessible to the web.
Maybe my example with the url was a misleading.

With the fine tuning, I am a little bit lost here :(

But I can say, if I request a file, which is not known as static file by plesk as default, for example webp or any other, the proxy is working like expected.
When I use a file like png/jpg/css etc. I get a 404, because nginx is looking locally for the file and then fails.
 
Back
Top