N
N
Nikita Dergachov2017-10-08 11:21:32
Laravel
Nikita Dergachov, 2017-10-08 11:21:32

How to make a link work only for one ip address?

There is a file sharing service, it has links to download files. How to make the link work only for one ip address?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
Pavel Kornilov, 2017-10-08
@KorniloFF

if($_SERVER[REMOTE_ADDR] === '....') echo "<a href='/'>Hidden</a>";

D
Dmitry Bay, 2017-10-08
@kawabanga

Write down the IP when you first download, generating a link.
In this case, the file must be given not in the form of a direct path, but through a proxy script that will also check the ip and give the file.
Perhaps there is a point in unique links that live for some limited time.

K
Konstantin Malyarov, 2017-10-08
@Konstantin18ko

I don’t know how everything is arranged there, but on the download page, paste this code, changing it to your parameters

@if($_SERVER[REMOTE_ADDR] === '192.168.1.1')
        <a href='{{route('page.download')}}'>Download</a>;
@endif

B
Boris Korobkov, 2017-10-08
@BorisKorobkov

It is better to do this not in PHP, but in Nginx: nginx.org/ru/docs/http/ngx_http_secure_link_module.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question