Score:0

Basic HelloWorld Nginx proxy_pass giving 502 bad gateway : WSL Ubuntu

uz flag

I am simply trying to learn nginx load-balancing, and have a very basic nodejs hello world server, 4 instances of which are running in port 3001-3004.

I want to load-balance across them, but proxy_pass will not work. Can someone please help ?

Below is my nginx.conf file. Nginx is running in WSL ubuntu

events {

}

http {

  upstream allbackend {
    server 127.0.0.1:3001;
    server 127.0.0.1:3002;
    server 127.0.0.1:3003;
    server 127.0.0.1:3004;
  }

  access_log /path/to/log/nginx/access.log;
  error_log /path/to/log/nginx/error.log;

  server {

    listen 8888;
    location / {
      # return 200 "hello from nginx"; # only this works
      proxy_pass http://allbackend; # this fails
    }
  }
}
Michael Hampton avatar
cz flag
Check the error log.
Score:0
uz flag

Fixed.

The issue was that I was running node servers in my local (non-wsl) windows, whereas nginx was running in WSL.

Once I started the node servers inside WSL, all things worked well.

djdomi avatar
za flag
remind to accept your own anwser, else we will reminded until the infinity to answer this question
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.