trouble with static content (Revised)

Francis Daly francis at daoine.org
Sun Nov 7 13:23:29 UTC 2021


On Sun, Nov 07, 2021 at 07:01:58AM -0500, deeztek wrote:

Hi there,

> With the following configuration, I get static content on the /admin
> location but NOT the / location:

Can you give some specific examples of requests that you make, responses
that you get, and responses that you want to get instead?

Normally, in the context of nginx, "static content" means "requests
that should be served by nginx direct from the filesystem". It is not
immediately clear to me that that is the meaning that you are using.

The "location" blocks that you have defined (apart, perhaps, from anything
that was "include"d from other files, are

>         location /.well-known {
>         root /var/www/html/;
>         }

> location / {
>         set $upstream_authelia http://127.0.0.1:9091;
>         proxy_pass $upstream_authelia;
>     }

> location ~* .(?:ico|css|js|gif|jpe?g|png|woff2|map)$ {
> expires max;
> }

> location /admin/ {
>         proxy_pass http://localhost:8888;
> }

So for each request that you make, it should be clear which on location{}
is used to serve it.

Any request that matches the regex location will be served from the
filesystem, using whatever the compile-time default "root" value was.

Any other request that starts with /.well-known will be served from
below /var/www/html/.

Any other request that starts with /admin/ will be proxy_pass'ed to one
other server.

Any other request will be proxy_pass'ed to a different other server.

So, for example, a request for /one.js will come from (something like)
/usr/local/nginx/html/one.js; and a request for /admin/two.js will come
from /usr/local/nginx/html/admin/two.js; or give a 404 if the file does
not exist.

What response do you get from

  curl -v https://your_domain/one.js

?

> However, if I remove the following from the configuration above, I get
> static content from the / location but NOT the /admin location:

In the case, the same thing applies, except now the request doe snot
come from the filesystem.

/one.js will be proxy_pass'ed to port 9091, and /admin/two.js will be
proxy_pass'ed to port 8888.

When you don't get the static content -- what do you get instead?

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list