two docker containers are running two websites with apache as a server on port 60000 and 60002
nginx docker(created with nginx docker image) as a reverse proxy hosted on port 61001
the ip address is 10.0.2.15
when http://10.0.2.15:61001/app1 is called, it returns a blank website
after checking network, its returning 502 bad gateway
server {
listen 80;
server_name 10.0.2.15;
location /app1/ {
proxy_pass http://10.0.2.15:60000/;
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;
}
location /app2/ {
proxy_pass http://10.0.2.15:60002/;
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;
}
}
this is the default.conf file in the nginx docker container
ideally it should be going to http://10.0.2.15:61001/app1/static/ for all the content
and the react apps are all applications with routes as well
or is there any better way implementing this
2
Answers
you can try this
You cannot listen on port 80 by establishing a connection through port 61001. You need to listen on port 61001
You need to configure the nginx settings as follows: