B
B
ByRon2017-01-13 23:44:18
Node.js
ByRon, 2017-01-13 23:44:18

ngnix + node config, to whom where and to whom?

Where to write something so that the application is simply at the URL address, and not at the URL: 3000 address.
I tried googled examples, nothing, it works for 3000, without it it just gives a list of files on the host ... in general, the question is - how to tell ngnix that app.js is the start page, and what to say to app.js so that it apparently makes friends with him.
I'm not a real welder, please don't kick me :)
Of course, I googled examples, but nothing helped, the ngnix config for the site didn't help me.
Yes, I asked the admins - the answer is: you are a cancer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Shatokhin, 2017-01-14
@iShatokhin

Use port 80, not 3000.
And here is an example config:
nginx/sites-available/default

server {
    listen 80;

    server_name example.com;

    location / {
        proxy_pass http://localhost:8080;
        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;
    }
}

app.js (node)
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World');
}).listen(8080);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question