[SOLVED] how to make a URL available only during certain times of day
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to make a URL available only during certain times of day
Hello,
Does someone know of a tool that can be used to that will produce this result:
When navigating to specific URL M-F 8 am to 5 pm any computer will receive an error message or be re-routed to a static site that something such as, "This site is only available during these hours."
When navigating to that same URL during the other hours it will work as intended.
The function needs to work with no intervention needed to the browsing computer or network.
You could implement the iptables rule on the outermost firewall, or on the very machine which you are controlling access to.
I'm not sure about returning a specific "Page not found" error - to go that route, you may need to do something right within apache, and I am not familiar with how to do that at all. Someone else may have an idea. Or, perhaps during the "off" time of day, requests are simply forwarded to your special "During business hours only.." message (again using iptables, not apache. One rule for the good hours, forwards as expected, and a second rule for the bad hours, forwarded to the "we're closed" page.).
Googling for "iptables time of day" also returns loads of results. And, the iptables manpage and main site ( http://www.netfilter.org/ ) should also be of help.
Once you have your rule(s) written, if they aren't working as expected, show us what you've got and perhaps someone can help you debug.
Cheers & good luck!
Last edited by GrapefruiTgirl; 11-13-2010 at 09:28 AM.
I think the iptables approach is only suitable if there is only one site hosted on the machine (maybe I misunderstand that).
Wouldn't this be a simple copy job using cron?
I don't believe it would matter how many sites were hosted on a given machine. The time of day rule would just act on traffic FROM internet, TO <whatever destination(s)>, so it could be done for a single site, or many.
But, you're right, a cronjob might be another way to do this also. Perhaps a cron that adds and removes iptables rules (or rulesets) at the specified times - is this what you're thinking TobiSGD? IMO slightly clunkier than using iptables alone, plus it potentially interrupts the network momentarily during the ruleset change, but it could work...
Perhaps a cron that adds and removes iptables rules (or rulesets) at the specified times - is this what you're thinking TobiSGD?
No, that was not what I was thinking of, but it is a much more intelligent approach. I was thinking of copying a "Sorry, this service is only available between ..."-site to the www-folder and copying the original index.html back at given times. But this will not work with bookmarks set to subpages.
If you are connecting to the internet using a modem/router, then you are likely to find this functionality available in the firewall rules setup for the modem/router.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.