【发布时间】:2018-06-04 23:13:42
【问题描述】:
我刚给自己买了一个新的树莓派 3,并在上面安装了带有节点的 nginx。 nginx 网络服务器已启动并正在运行。但不知何故,我没有让我的网站工作的 javascripts。我是否需要为我的网络服务器的每个位置启用 javascript,或者是否有可能以我只适用于我服务器上的每个站点的方式设置节点?
在这里你可以看到我的网站的目录层次结构:
#########################################
### 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 #
# | ... #
#########################################
当您访问我的网站 (http://strtpg.xyz) 时,会显示 /www/var/ 的主页。这是一个集线器,我可以访问服务器上托管的所有其他站点。您可以通过将其文件夹名称附加到链接来访问不同的站点:例如“http://strtpg.xyz/proj1”或“http://strtpg.xyz/proj5”。有些网站有 javascript,有些没有。
这是我来自/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;
}
}
我尝试让 node 与我的网站一起工作的所有内容都被注释掉了,所以我至少可以看到网站本身。
【问题讨论】:
-
这一切与 node.js 有什么关系?我似乎找不到与 nodeJS 的连接。你把我弄糊涂了。
-
我不需要 node.js 在我的服务器上运行 javascript 吗?
标签: node.js linux nginx raspberry-pi3