A
A
Alexander N++2016-08-22 17:05:28
Node.js
Alexander N++, 2016-08-22 17:05:28

How to set up a log in ngnix + nodejs, where to write something for the http request log?

upstream app_node {
  ip_hash;
  server server_local1 weight=10;
        server server_local2 weight=20;
        server server_local3 weight=50;
}

server {
   listen 80 default_server;
   ...
   access_log  /var/log/nginx/app.access.log main;
   error_log   /var/log/nginx/app.error.log notice;
   rewrite_log on;

   fastcgi_buffers 256 16k;
   fastcgi_buffer_size 32k;

   location /rest {
    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://app_node;
    proxy_redirect off;
  }
       ...
      # дальше идут настройки php
}

When requests go to php, everything is logged, when the log is empty on the url node.
How to fix it ?
UPD
rewrite_log on;
if you remove the idea, there should be logs for all requests (did not check),
but since pm2 writes logs of everything that is displayed through console.log, I made a log in the application and that's enough for me.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question