简体   繁体   中英

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.

请求 10.0.1.2:3000 和 10.0.15.19 的 gif

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.

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.

显示大量 nginx.exe 进程的任务管理器

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM