uPaymeiFixit
uPaymeiFixit

Reputation: 353

Basic NGINX proxy_pass example is serving 404's

I have an very basic out-of-the-box NGINX server running on a Windows machine at http://10.0.15.19:80. I'm attempting to use it as a proxy to get around a CORS restriction. I have the following nginx.conf, which from every example I've seen sounds like it should redirect any traffic from http://10.0.15.19 to http://10.0.1.2:3000.

events {
    worker_connections  1024;
}
http {
    server {
        listen       80;
        server_name  10.0.15.19;

        location / {
            proxy_pass http://10.0.1.2:3000/;
        }
    }
}

Instead of serving the content from http://10.0.1.2:3000 I get the default index.html page inside the included html folder. Similarly, if I were to go to http://10.0.15.19/any/path I get a 404 even though http://10.0.1.2:3000/any/path works correctly.

gif of requests to 10.0.1.2:3000 and 10.0.15.19

EDIT: I've noticed that even after commenting out the entire server block of my configuration, it's still serving content from the included html folder. This makes me think there is another server configuration running that I'm not aware of, but I'm not sure where. I downloaded NGINX from here, and I assume all configuration files exist within this folder.

Upvotes: 0

Views: 135

Answers (1)

uPaymeiFixit
uPaymeiFixit

Reputation: 353

It turns out this was because simply closing the window that pops up when you open nginx.exe doesn't actually kill the process. And in Windows you can apparently have multiple services bound to the same port, so I had many servers serving on port 80. Killing all of these processes and relaunching with the originally posted config fixed my problem.

task manager showing lots of nginx.exe processes

Upvotes: 2

Related Questions