I just got myself a new raspberry pi 3 and installed nginx with node onto it. The nginx webserver is up and running. But somehow I don't get the javascripts of my website work. Do I need to enable the javascript for each location of my webserver or is there the possibility to set node up in a way I just works for every site on my server?
Here you can see the directory hierarchy of my websites:
#########################################
### Directories ###
#########################################
# /www/var/ #
# | - > index.html (the hub/mainpage) #
# | proj1/ #
# | | - > index.html (website 1) #
# | proj2/ #
# | | - > index.html (website 2) #
# | | - > js/somescript.js #
# | proj3/ #
# | | - > index.html (website 3) #
# | | - > js/anotherscript.js #
# | proj4/ #
# | | - > index.html (website 4) #
# | proj5/ #
# | | - > index.html (website 5) #
# | | - > js/morescript.js #
# | ... #
#########################################
When you go to my website (http://strtpg.xyz) the mainpage out of /www/var/ is beeing shown. It's kind of a hub where I got access to all other sites hosted on the server. And you can access the different sites by appending it's folder name to the link: e.g. 'http://strtpg.xyz/proj1' or 'http://strtpg.xyz/proj5'. Some of the sites got javascript and some don't.
And this is my config file from /etc/nginx/sites-available/
:
# Server configuration
#upstream pnkpnd {
# server localhost:3420;
# keepalive 8;
#}
server {
listen 0.0.0.0:80;
listen [::]:80;
server_name localhost;
index index.html index.htm;
location / {
root /var/www;
try_files $uri $uri/ =404;
# Default root of site won't exist.
#return 410;
}
location /strtpg {
root /var/www;
try_files $uri $uri/ =404;
}
location /dshbrd {
root /var/www;
try_files $uri $uri/ =404;
}
location /pnkpnd {
root /var/www;
try_files $uri $uri/ =404;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forward-For $proxy_add_x_Forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-NginX-Proxy true;
# proxy_pass http://strtpg.xyz/;
# proxy_redirect off;
}
location ~ /\.ht {
deny all;
}
}
All the stuff I tried out to get node working with my websites is commented out, so I can at least see the website itself.