简体   繁体   中英

nginx proxy_pass doesn't work to localhost

I have my node app running locally on port 3000, I've set up nginx but for some reason it doesn't work right.

I tried to proxy_pass to http://google.com and it worked, but when I change it to http://localhost:3000 I get the nginx error page.

the app is running, i opened port 3000 on my server and I can access it on my http://domain:3000 .

 server {
    listen       80;
    listen       [::]:80;
    server_name  mydomain.com;
    # root         /usr/share/nginx/html;

    location / {
            proxy_pass "http://localhost:3000";
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

any idea why the proxying doesn't work properly?

Thanks.

This was SELinux issue - blocked http requests.

this command solved it:

setsebool -P httpd_can_network_connect true

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