1

I am currently trying to run a Node server on a Raspberry Pi. Full disclosure: I have no knowledge of servers, I am an interface designer and developer, so command lines are an unknown to me, don't expect prior knowledge.

I tried to follow many instructions on installing Nginx, but now it fails and I can't it to point to a line where I could check where it fails.

Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.

The journalctl -xn says there is no file, and the other one gives me details, but I cant make heads or tails of it:

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Fri 2017-07-07 12:43:36 EDT; 38s ago
  Process: 1071 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

I followed an instruction where it said that it's best to copy the sites-available/default rather than edit it, and here is what I did:

server {
  listen 80 default_server;
  listen [::]:80 default_server;

  root /var/www/osc-api/www;

  index index.html; 

  server_name _;

  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
  }
}

server {
  listen 80 default_server;
  listen [::]:80 default_server;

  server_name osc-api;

  location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://127.0.0.1:3000/;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

And yes, it is symlinked to the sites-enabled. I guess I am looking for info on how to understand how to fix this issue.

5
  • Please verify that port 80 is not used by apache or some other process. Commented Jul 7, 2017 at 17:11
  • @AtulAgrawal I do I check that? There is actually nothing else than Nginx on the Pi at this time. Your comments makes me think: is it possible that the two server block require a different port? Commented Jul 7, 2017 at 19:40
  • @AtulAgrawal That seems to be correct, I needed a different port per server {} block. Does that sound good enough to you? Commented Jul 7, 2017 at 20:21
  • You don't really need that until your server name is different.The point is there any other process which is consuming port 80? Commented Jul 8, 2017 at 0:51
  • This surely help:stackoverflow.com/questions/33055212/… Commented Jul 8, 2017 at 0:52

1 Answer 1

1

Please verify that port 80 is not used by apache or some other process. Please see this link Nginx multiple server blocks listening to same port

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.