Answer the question
In order to leave comments, you need to log in
How to set up the launch of three applications on the server with a bunch of nginx and react?
Hello, what is the problem:
Three applications should be running on the server:
1. React-create-app, port 3000: this is a landing page, it is located at url: example.com/
2. React+route+express, port 9000: this is personal office, when a person enters from the landing, he should be transferred to example.com/home/ - another application works along this path.
3. The server which is started on 8080 working from a DB. requests from the site come to it, they are sent to example.com/server/
When the second application is restarted, it crashes, the file is in nginx
root /this/my/folder;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
location / {
proxy_pass http://localhost:3000;
root /this/my/folder/one/build;
}
location /home/ {
proxy_pass http://example.com:9000/;
root /this/my/folder/two/dist;
}
location /server/ {
proxy_pass http://example.com:8080/;
}
try $uri $uri/ /index.html
doesn't help. <script src="/js/app.bundle.js"></script>
to <script src="js/app.bundle.js"></script>
, then the page is loaded, but when reloading the page does not work.
Answer the question
In order to leave comments, you need to log in
With God's help, I found the answer to this question:
Firstly, the root directive was really not needed, proxy_pass was enough.
Secondly, the second application accesses the address example.com/home/
, added to index.html the absolute path not <script src="/js/app.bundle.js"></script>
, but <script src="/home/js/app.bundle.js"></script>
, and so on to all paths in the index of the second application
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question