带节点的Nginx服务器返回js代码

时间:2017-05-10 20:07:48

标签: node.js nginx

我学习节点。我删除了ubuntu服务器,安装了nodejs并尝试使用一些指南来设置nginx。一切看起来很好,但...服务器返回我的app.js代码而不是索引页面。我做错了什么?谢谢!

hack-it-up.ru.conf :

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name hack-it-up.ru www.hack-it-up.ru;

    include /etc/nginx/snippets/letsencrypt.conf;

    location / {
        return 301 https://www.hack-it-up.ru$request_uri;
    }

}


server {
    server_name www.hack-it-up.ru;
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server ipv6only=on;

    ssl_certificate /etc/letsencrypt/live/www.hack-it-up.ru/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.hack-it-up.ru/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/www.hack-it-up.ru/fullchain.pem;
    include /etc/nginx/snippets/ssl.conf;

    root /var/www/hack-it-up.ru;
    index app.js;
    location / {
        try_files $uri $uri/ =404;
    }
}


server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name hack-it-up.ru;

    ssl_certificate /etc/letsencrypt/live/www.hack-it-up.ru/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.hack-it-up.ru/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/www.hack-it-up.ru/fullchain.pem;
    include /etc/nginx/snippets/ssl.conf;

    location / {
        return 301 https://www.hack-it-up.ru$request_uri;
    }
}

1 个答案:

答案 0 :(得分:0)

我得到了这个错误,因为我犯了错误的索引文件。必须是index /bin/www