K
K
Kirill Gavrilov2019-08-12 06:02:04
Nginx
Kirill Gavrilov, 2019-08-12 06:02:04

How to set up nginx to proxy for nodejs and CRA?

Hello!
I have an nginx server and on it I have a site on node.js.
I configured proxy_pass on the root location and the site works, but my admin panel is made on react.js, namely on CRA.
I tried to run CRA as well as node.js and set proxy_pass to 3000 port, but in the end I get a blank page, as if the script does not run at all. After that, I decided that it’s possible to just run the build version as a static site, and this is also a problem, everything starts well at the root location, and if you specify location /manager, nothing happens, error 404
Here is my nginx.conf file

events {}

http {

        include mime.types;

        server {

                listen 80;
                server_name site.ru;

                location / {
                        proxy_pass http://localhost:5000/; 
                }

                # Exact match
                location = /manager {
                        root /home/vseriousv/www/manager/build;
                }
        }
}

It turns out that the site itself should be launched by the root request, it is located on my port 5000, and the admin panel should be launched by url /manager

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2019-08-12
@gavrilovskirill

try_files may need to be added?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question