I have Nginx server running on machine, I set reverse proxy to angular docker app which runs on localhost:4200. Rerouting works well but angular app can’t load static assets. Bellow is part of my conf.d file. If I use location to the root ( / ) everything works well looks like I missing something :(.
`
location /auth {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:4200/;
proxy_read_timeout 90;
}
`
I tried to set basehref in angular app to /auth but it doesn’t work.
2
Answers
You don’t need angular container to reverse the traffic, You can use multi stage option in Dockerfile to compile the angular project and copy the dist files into nginx container.
You should add blow configuration into nginx container.
I struggled with this as well and it seems when you change the location to something other than root, it will try to grab assets from the reverse proxy itself at /etc/nginx/html/assets/img/example.png
Assuming you store your statics in the assets folder, I believe adding this may fix it: