Issue
I have to deploy an SPA to an nginx server. The backend API must be in the same server but with different domain and port.
Let's say the frontend domain is front.example
and the backend domain is back.example
.
- The frontend SPA should be running at
http://front.example:80
- The backend API should be running at
http://back.example:4444
What is the correct configuration in nginx server?
Solution
Here is the solution:
/etc/nginx/sites-enabled/front.example
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm;
server_name front.example www.front.example;
location / {
try_files $uri $uri/ /index.html;
}
}
/etc/nginx/sites-enabled/back.example
server {
server_name back.example www.back.example;
location / {
proxy_pass http://0.0.0.0:4444;
}
}
NOTE: Be sure to include only sites-enabled/*
in etc/nginx/nginx.conf
.
Answered By - glinda93
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.