I have an nginx container with -p 8080:80
. I am trying arrange my proxy_pass
so that my browser client can go to <ip of container server>:8080/app
and it will be redirected to another container listening with -p 8000:8000
as <ip>:8000
(no /app
). I have some pretty simple config files:
default.conf
:
server { listen 80; listen [::]:80; server_name localhost; error_log stderr debug; access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
app.conf
:
server { listen 80; server_name mydomain.com; error_log stderr debug; location /app { proxy_pass http://<ip of server running containers>:8000/; } }
I have played around with different combinations of trailing slashes on location
and proxy_pass
. The config files as shown above give me a 301 error if I type <ip>:8080/app
into the browser and gives me the starting page of the app if I use <ip>:8080/app/
(trailing slash), but then other requests from the app get 404. If I make the location /app/
, the app tries to start but then says "Please enable java script". The container app works if I go directly to it (<ip>:8000
). I believe that nginx is somehow appending /app
or /app/
to the proxy url and this messing up the app when it tries to GET resources, but I can't seem to find a way to go to the proxy url as is in the proxy_pass
. I was going to look into using rewrite but thought I'd post this first in the hope that someone will know how to write the config files that will work.