1

nginx load balancer still not working since yesterday. I run a microservice on 3 docker containers on port 4001,4002,4003, on my WSL2 instance, accessed through browser (sudo docker run -d -p 4003:80 --name asciiflow3 dominicbreuker/asciiflow2). I don't have nginx installed, so its just from a nginx container. Build the docker image sudo docker build -t nginx-asciiflow . for nginx and run with sudo docker run --name nginx-asciiflow --network host -d nginx-asciiflow When I open http://localhost/ I expect the homepage of the service to display, instead it's just nginx default. Thing is,accessing http://localhost:4001/ and the like correctly redirects to the microservices page. My config file is

events { worker_connections 1024; }

http {
  upstream worker {
    server localhost:4001;
    server localhost:4002;
    server localhost:4003;
  }

  server {
    listen 80 default_server ssl;
    location / {
      proxy_pass http://worker;
      proxy_set_header Host $host;
      proxy_redirect off;
    }
  }
} 

I've tried using default_server only, then without both default_server ssl. I've changed outgoing ports to 8080. I've tried extending the url to http://worker/index and change location / to location /index but accessing localhost/index still leads to nginx 404 page. Same with location /worker/index/ and https://worker/index/. I've tried it with and without proxy_set_header and proxy_redirect. I made sure containers use the right port (e.g. 4001:80), checked for semicolons, and made sure the url has no trailing slash. I've tried pulling out the upstream worker and server block, dropping http. There are no other nginx configs that override this file. I've been fixing this all night and nothing works. I'm tired, how do I fix this? My friends have successfully done this, and their advices didn't work.

I've read many other similar questions and none worked. Here is the list:

0

You must log in to answer this question.

Browse other questions tagged .