E
E
Elena2020-12-02 17:00:09
Nginx
Elena, 2020-12-02 17:00:09

Can't restart nginx with sudo systemctl restart nginx?

Hello! I'm trying to make frontend and backend on the same domain, I set up ports and when I do updates sudo systemctl restart nginx
gives an error:


Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

When doing just the backend:
server {
        listen 80;

        server_name project.gq www.project.gq;

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

then everything works, nginx is updated, and when I add the frontend to the port, this way:
server {
        listen 80;

        server_name api.project.gq www.api.project.gq;
        location / {
                proxy_pass http://localhost:3000;
                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;
      }

}
server {
        listen 80;
        server_name project.gq www.project.gq;
        root /home/project/project-frontend/dist;

}

it throws an error. Help me figure out what I'm doing wrong

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Elena, 2020-12-02
@Elena0394

Error in the length of the domain, the solution in the comments is in question

K
ky0, 2020-12-02
@ky0

sudo nginx -t, then fix the errors that this command will issue.
From experience - the vast majority of problems are from incorrect syntax of configs and all sorts of jambs with permissions to directories.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question