Answer the question
In order to leave comments, you need to log in
How to spawn two processes in nginx?
Deployment problems. I have a VPS and a Full stack application: a NodeJS API and a ReactJS client. Raised the server on nginx, got SSL with the help of certbot. Now I have a full client under HTTPS and a domain name. But in my thoughts, it should have interacted with an api that just works on pm2, it turned out that this is not possible, because the process raised via pm2 works using an insecure protocol and the client gives an error:
xhr.js:210 Mixed Content: The page at 'https://my_domain_name.ru/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://ip:port/'. This request has been blocked; the content must be served over HTTPS.
https://api.domain_name.ru/ - API (with ssl)
https://domain_name.ru/ - CLIENT (with ssl)
Answer the question
In order to leave comments, you need to log in
Why all this complexity with subdomains when everything is relatively simple
upstream client-upstream {
server 0.0.0.0:3000;
keepalive 15;
}
upstream back-upstream {
server 0.0.0.0:8000;
keepalive 15;
}
server {
listen ${HOST_IP}80;
server_name ${PROJECT_NAME} www.${PROJECT_NAME};
server_tokens off;
root /var/www/prod/public;
index index.php index.html index.htm;
location / {
proxy_pass http://client-upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_upgrade;
proxy_set_header Host $host;
}
location /api {
proxy_pass http://back-upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
this is called a virtual host.
raise two virtual hosts, in each you raise a proxy for your processes....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question