0

I'm trying to deploy an app through docker containers and reverse proxy it to my destination endpoint.

My docker compose file looks like this:

version: '3.4' services: monitor.api: image: ${DOCKER_REGISTRY-}monitorapi ports: - "5001:443" build: context: . dockerfile: monitor.API/Dockerfile webapp: image: ${DOCKER_REGISTRY-}monitorwebapp ports: - "4205:443" - "4206:80" build: context: ./monitor-webApp args: - BASE_API_URL=${BASE_API_URL} dockerfile: Dockerfile 

Both of the containers are getting built and running successfully. To access them I'm trying to set up a Nginx server with such config:

server { listen 80; server_name <HOST IP>; sendfile on; default_type application/octet-stream; gzip on; gzip_http_version 1.1; gzip_disable "MSIE [1-6]\."; gzip_min_length 256; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_comp_level 9; root /usr/share/nginx/html; location /monitorwebapp/ { proxy_pass http://<HOST IP>:4206/; 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 /monitorapi/ { proxy_pass https://<HOST IP>:5001/api/; 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; } } 

So with that, my expectation, would be if I go to http://HOSTIP/monitorwebapp I should get my webapp. However, I'm only getting 404 and the only way for me to access it is through: http://HOSTIP:4206.

There is nothing in the error logs as well. Any ideas how I could fix this?

1
  • there is nothing in the error logs - which logs? nginx? that would indicate that the 404 comes from the httpd inside the container. Check its logs as well. Commented Nov 15, 2023 at 9:41

1 Answer 1

0

I've used a similar configuration but with a specifically configured isolated bridge network; AND nginx as a docker container. Then you don't need https in an isolated bridge network - as it's all inside your single host.

So in the docker compose to have an isolated bridge network you would have.. (I haven't got all the indents for yml correct). Nor have I put in the section for nginx..

monitor.api ... networks: - <isol_bridge_network> webapp: ... networks: - <isol_bridge_network> networks: <isol_bridge_network>: 

And then in the nginx configuration. Add the internal DNS resolver. And put the proxy pass to point to the service name and port on the bridge network - rather than the external IP address and port. to be clear port 4206 and 5001 are externally visible ports.

location /monitorwebapp/ { resolver 127.0.0.11 valid=10s; set $files monitorwebapp:80; proxy_pass http://$files; ... } location /monitorapi/ { resolver 127.0.0.11 valid=10s; set $files monitorapi:80; proxy_pass http://$files; ... } 

hope this all makes sense..

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.