Score:0

Nginx Reverse Proxy custom location not serving static files

ps flag

I'm trying to serve 2 different websites under the same subdomain depending on the location.

Using the GUI from Nginx Proxy Manager Docker container I've managed to set up the initial domain https://foo.bar.baz that redirects to another Docker container http://dockercontainer:port.

By editing the "Custom locations" tab I've been able to set up a redirect from https://foo.bar.baz/test/ to http://dockercontainer:anotherport/

However, the website isn't loading any of the resources since it doesn't seem to be redirecting the resources requests and I'm getting 404'd for requests such as https://foo.bar.baz/test/styles.css.

Current .conf relevant lines:

location /test/ {
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-Scheme $scheme;
  proxy_set_header X-Forwarded-Proto  $scheme;
  proxy_set_header X-Forwarded-For    $remote_addr;
  proxy_set_header X-Real-IP          $remote_addr;
  proxy_pass       http://foo.bar.baz:4123/;

<snip>

  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $http_connection;
  proxy_http_version 1.1;

}

location / {
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $http_connection;
  proxy_http_version 1.1;

  # Proxy!
  include conf.d/include/proxy.conf;
}

I've tried searching around for different solutions but some of them weren't relevant or similar to this case, and others were based on modifying the source code of the website, which I'm not able to do.

faizan avatar
in flag
what do you get when you access http://foo.bar.baz:4123/style.css ?
ws flag
Where are your log entries?
Shadark avatar
ps flag
@faizan I can't get a connection when I access that URL. I'm guessing that's because "base" foo.bar.baz redirects to dockercontainer:8080 (inside the custom network in Docker) but foo.bar.baz/test would've redirected to dockercontainer:4123 , different ports.
Shadark avatar
ps flag
@symcbean Where would I be able to get logs about what's happening? Didn't knew that there were logs for all requests, that'd be very helpful.
ws flag
The log locations (and the contents for the access_log) are defined in your nginx config.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.