ash-jc-allen / short-url

A Laravel package for creating shortened URLs for your web apps.
MIT License
1.25k stars 157 forks source link

如何获取真实的IP? #231

Closed gyp719 closed 7 months ago

gyp719 commented 8 months ago

使用了 Octane 后 获取的 ip 都会是 127.0.0.1, 如何获取真实的IP?

NGINX

location @octane {
        set $suffix "";

        if ($uri = /index.php) {
            set $suffix ?$query_string;
        }

        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        proxy_pass http://127.0.0.1:8000$suffix;
    }
gyp719 commented 7 months ago

The ip obtained after using Octane is always 127.0.0.1, how to get the real IP?

ash-jc-allen commented 7 months ago

Hey @gyp719! Unfortunately, I've never used Octane before so I'm not too sure about a solution for this one.

Would the solution mentioned in this issue solve your problem? 🙂 https://github.com/laravel/octane/issues/371

gyp719 commented 7 months ago

Thank you