kazeburo / Gazelle

Preforked Plack Handler for performance freaks
https://metacpan.org/release/Gazelle
Other
74 stars 19 forks source link

REMOTE_ADDR not set in $env? #32

Closed djzort closed 7 years ago

djzort commented 7 years ago

When running with Gazelle with Plack::Middleware::Throttle::Lite I get the following warning on each request: Use of uninitialized value in join or string at /opt/plenv/versions/5.26.0/lib/perl5/site_perl/5.26.0/Plack/Middleware/Throttle/Lite.pm line 280.

This is the code in question in the middlewar:

# Requester's ID
sub requester_id {
    my ($self, $env) = @_;
    join ':' => 'throttle', $env->{REMOTE_ADDR}, ($env->{REMOTE_USER} || $self->defaults->{username});
}

I believe that $env->{REMOTE_ADDR} is not set by Gazelle?

I am running with Gazelle like this:

/opt/plenv/versions/5.26.0/bin/start_server \
    --path /run/etd.sock \
    -- \
    /opt/plenv/versions/5.26.0/bin/plackup \
    -s Gazelle \
    --max-workers 5 \
    --max-reqs-per-child 1000 \
    --min-reqs-per-child 800 \
    --app script/etd.psgi

The default HTTP::Server::PSGI server has no such warning.

kazeburo commented 7 years ago

REMOTE_ADDR is unavailable with unix domain socket. Please consider to use Plack::Middleware::ReverseProxy.

djzort commented 7 years ago

Ok thanks that was very helpful.