Wednesday, 10 May 2017

Nginx server with node returns js code

I learning node. I taked ubuntu server, installed nodejs and trying to set nginx by using some guides. All looks fine but... server returned me my app.js code instead of the index page. What i did wrong? Thanks!

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;
    }
}



via Nikita M

No comments:

Post a Comment