This is first time using nginx and nodejs. I have two apps one is built using django and other is built using nodejs (expressjs +openvidu). I am trying to configure nginx, django app works fine, I am having trouble with nodejs. nginx is not serving js files. I am getting the below error in console,(I suspect it is because browser is not able to find JavaScript file) both of my js files present under public folder.
Uncaught SyntaxError: Unexpected token '<'
Could you also suggest me if this is not the proper way to deploy django and nodejs
Below is my nginx configuration. /meeting is the node app.
server {
server_name sophie.ovgu.de;
location /meeting {
proxy_pass https://localhost:5000;
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 /videoapp {
proxy_pass http://unix:/run/gunicorn.sock;
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;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/sophie.ovgu.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sophie.ovgu.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = sophie.ovgu.de) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name sophie.ovgu.de;
return 404; # managed by Certbot
}
Please note "proxy_pass https://localhost:5000" this should be https as openvidu server requires it. Please refer this link
This is my folder structure
├───node_modules
├───public
│ app.js
│ openvidu-browser-2.18.0.js
│───views
index.ejs
│ openviducert.pem
│ openvidukey.pem
│ package-lock.json
│ package.json
│ README.md
│ server.js
This is how I am calling js file in index.html
> <script src="/openvidu-browser-2.18.0.js"></script>
> <script src="/app.js"></script>
> <script>