feat: log real ip
This commit is contained in:
parent
232c3907a7
commit
8b5aa07b1f
@ -31,6 +31,9 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location ^~ /http {
|
location ^~ /http {
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header REMOTE_ADDR $remote_addr;
|
||||||
proxy_pass http://localhost:8080;
|
proxy_pass http://localhost:8080;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,11 @@ $loop->run();
|
|||||||
|
|
||||||
|
|
||||||
function handler(Psr\Http\Message\ServerRequestInterface $req) {
|
function handler(Psr\Http\Message\ServerRequestInterface $req) {
|
||||||
|
$ip = $req->getHeader('REMOTE_ADDR')[0];
|
||||||
$url = $req->getUri()->getPath();
|
$url = $req->getUri()->getPath();
|
||||||
// strip start /
|
// strip start /
|
||||||
$url = substr($url, 1);
|
$url = substr($url, 1);
|
||||||
echo "request url: ", $url, PHP_EOL;
|
echo "IP:", $ip, ", request url: ", $url, PHP_EOL;
|
||||||
|
|
||||||
if (substr($url, 0, 4) !== 'http') {
|
if (substr($url, 0, 4) !== 'http') {
|
||||||
return serveStaticFiles($url);
|
return serveStaticFiles($url);
|
||||||
|
Loading…
Reference in New Issue
Block a user