I'm having trouble setting up Nginx site configuration file. So basically I'm serving 3 sites:
- Dashboard
/dashboard(react-based, operates atxxx/xxx/build/index.html) - API
/api(node-based, operates using a proxy-pass and it works perfectly - Homepage
/(static, operates atxxx/yyy/zzz/index.html)
My Nginx file looks as follows:
server {
listen 80;
server_name mydomain.com;
server_name xxx.xxx.xxx.xxx;
access_log /var/log/nginx/xxxxx;
error_log /var/log/nginx/xxxxx;
location /dashboard/ {
root /var/www/xxxxx/build;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://localhost:5050/;
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 / {
root /var/www/xxxxxx;
index index.html;
try_files $uri /$uri /index.html;
}
}
The problem lays mainly in the /dashboard path. For some reason it redirects to the homepage and never returns the actual dashboard.
I'm quite inexperienced in Nginx, so I'm not quite sure how to even debug it.