Current State
·Debug.php is set to be accessible only from the IP address of the administrator
(Provider contract with irregular IP address changes)
·If the IP address is changed, you will not be able to access debug.php, so you will notice the address change.
·When I realized it, I went to https://www.cman.jp/network/support/go_access.cgi, copied the IP address manually, rewritten the IP address value of .htaccess below, and uploaded .htaccess by FTP
.htaccess
<Files~"^debug\.php$">
order deny, allow
deny from all
allow from 111.222.33.444
</Files>
What do you want to do
·When I noticed the IP address change, I thought it would be convenient if I could dynamically change the IP address of .htaccess via PHP by accessing a previously specified page.
·It would be best if it were processed automatically every time the IP address is changed, but I would like to know if there is a way to reduce the burden of manual processing when I notice that the IP address is changed.
This answer assumes that simple access restrictions are sufficient.
You can put a script on the server that you can call from the web and manually access it from your browser when you want to change it, leave it open in your browser and automatically reload it with meta refresh, or use a task scheduler or cron to access it automatically.
1 can be taken from the $_SERVER
variable if it is PHP.
2 is like a programming practice task, so it can be found in any reference book.
If you're serious about it as a security feature, the above is not enough.Because you don't know what level of security you need, and you can't determine if your understanding is correct, it is recommended that you consult an expert.
Perhaps you want to automatically upload .htaccess to the rental server when your home (or company) WAN side address changes.
The problem is how to detect changes in WAN side addresses from routers in your environment.
1. If the router has that function, use it.
2. If HTTP connection to the router management screen is possible, connect regularly and read the information.
3. Periodically request and receive information from an external site that gives you an address.
In reality, it's 3.However, if you don't have a dedicated API that allows you to make requests for short intervals, it may cause you trouble.
So why don't you create an allow from All part of your render server and put an API there to return the source address?
If I gave you a wrong answer, your question is bad.
Ask questions so that the respondents don't expect or imagine.
© 2024 OneMinuteCode. All rights reserved.