Skip to content

Commit

Permalink
Update nginx config
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Paśnik committed Dec 11, 2023
1 parent a32d07e commit 68307c9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
12 changes: 11 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,22 @@ app.use((req, res, next) => {
const parser = new UAParser();
const userAgent = req.headers['user-agent'];
const result = parser.setUA(userAgent).getResult();
const referer = req.get('Referer');
let origin = '';
if (referer) {
try {
const url = new URL(referer);
origin = url.origin;
} catch (error) {
console.error(error.message);
}
}
visitors[ip] = {
lastSeen: ts,
ip: ip,
os: result.os,
browser: result.browser,
referer: req.get('Referrer')
referer: origin
};
}
next();
Expand Down
13 changes: 13 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ http {
autoindex on;
}

location /arenas/(.+) {
alias /var/www/app/public/arenas;
error_log off;
access_log off;
}

location /assets {
add_header Cache-Control "public, max-age=30672000";
alias /var/www/app/public/assets;
error_log off;
access_log off;
}

error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
Expand Down
3 changes: 2 additions & 1 deletion src/admin/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ router.get('/', (req, res) => {
uptime: formatUptime(os.uptime()),
usedmem: os.totalmem() - os.freemem(),
totalmem: os.totalmem(),
node: process.version
node: process.version,
appuptime: formatUptime(process.uptime())
});
});

Expand Down
22 changes: 20 additions & 2 deletions views/admin/system.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<td><%= hostname %></td>
</tr>
<tr>
<th>Uptime</th>
<th>System uptime</th>
<td><%= uptime %></td>
</tr>
<tr>
Expand All @@ -36,10 +36,28 @@
<th>RAM usage</th>
<td><%= Math.floor(usedmem / (1024 * 1024)) %>/<%= Math.floor(totalmem / (1024 * 1024)) %> MB</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="table-responsive">
<table>
<thead>
<tr>
<th>Node version</th>
<th width="50%">Key</th>
<th width="50%">Value</th>
</tr>
</thead>
<tbody>
<tr>
<th>Node.js version</th>
<td><%= node %></td>
</tr>
<tr>
<th>Node.js uptime</th>
<td><%= appuptime %></td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 68307c9

Please sign in to comment.