https://github.com/52cik/nginx-syslog
Nginx syslog protocol interface
https://github.com/52cik/nginx-syslog
Last synced: 2 months ago
JSON representation
Nginx syslog protocol interface
- Host: GitHub
- URL: https://github.com/52cik/nginx-syslog
- Owner: 52cik
- License: mit
- Created: 2017-04-18T06:47:22.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-24T04:49:40.000Z (about 8 years ago)
- Last Synced: 2025-03-01T05:45:29.691Z (3 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nginx-syslog
Nginx syslog protocol interface
[中文文档](README_CN.md)
## install
```sh
$ npm install --save nginx-syslog
```## usage
nginx config:
```nginx
log_format nodelog '{"ip":"$remote_addr","url":"$request_uri","status":"$status","ua":"$http_user_agent"}';
server {
listen 80;
# 其他配置
location ~ [^/]\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;access_log syslog:server=127.0.0.1:8514,tag=mylog,nohostname nodelog;
}
}
```node:
```js
const Syslog = require('nginx-syslog');const app = new Syslog({ port: 8514 });
app.on('message', (msg, rinfo) => {
console.log(rinfo);
console.log(msg);
});
```