0

Using nginx, im trying to set an endpoint for /test to redirect to a docker container i have running on the network on port 5000

I gets the the page correctly, however is unable to load the necessary assets for the page. Looking in the error log, it is looking in the wrong directory for the assets.

my current config:

server{
    server_name domain;
    listen 90;
    access_log /etc/nginx/conf.d/access.log;
    error_log /etc/nginx/conf.d/error.log;
location /test{
    proxy_pass http://myip:5000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    
}

}

This will return a blank page, however the title is correct and corresponds to the container name.

The strange thing is, when instead using the / location, it works perfectly fine:

server{
    server_name domain;
    listen 90;
    access_log /etc/nginx/conf.d/access.log;
    error_log /etc/nginx/conf.d/error.log;
location /{
    proxy_pass http://myip:5000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    
}

}

Looking at the access and error logs, when using the / location, it loads the files from /assets/icons/example.file. This directory doesnt actually exist on my machine, i assume this is from the docker container.

When using the /test location though, it attempts, and fails to load files from /usr/share/nginx/html/assets/icons/example.file, resulting in a blank page.

I have been stuck on this for days using all types of solutions found on the internet, any help would be appreciated.

HBruijn
  • 80,330
  • 24
  • 138
  • 209
  • Thanks HBruijn, using a subdomain seems to be an acceptable workaround for this issue, curious as to why location tags still dont work however, the other solutions didnt seem to work for me sadly. But a subdomain is a fine workaround, Thank again! – justinlime Mar 24 '23 at 11:27

1 Answers1

0

You can look at an example configuration here, I hope it helps.

GTP95
  • 11