Answer the question
In order to leave comments, you need to log in
How to configure nginx if nodejs server is mixed?
There is an application on nodejs (express), there are static URLs (for example mysite.com/:code) where you need to pull out the code and show either data from the database or make a redirect. And actually rest api.
Now nginx looks like this:
server {
server_name ***.com www.***.com;
root /var/www/html;
index index.html
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location /api/ {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://***:3000; # set the adress of the Node.js instance here
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question