Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
How to configure an Apache server/crontab/bash file to allow access at certain times during the day and/or from specific IPs?

I am attempting an exercise given by my instructor. We were tasked with setting up a VirtualHost that could be accessed mon-fri/1-5. On top of that, we must allow access to the site from IP "XX.XX.XX.XXX" at anytime.

Current crontab:

* 13 * * 1-5 root apachectl start
* 17 * * 1-5 root apachectl stop
* * * * * root ./bash

Bash file:

currIP=$(hostname -I)
case "$currIP" in
        *XX.XX.XX.XXX*)
              ???????
;;
esac

Can someone explain to me how I am going to serve this site to the IP without serving it to everyone at once?

Thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Lets say this is your config file.

/etc/apache2/httpd.conf

Run these commands :

sudo cp /etc/apache2/httpd.conf all.conf
sudo cp /etc/apache2/httpd.conf restricted.conf

Now create this script somewhere in your system :

#!/bin/bash

[[ "$1" = "all" ]] && { ln -s --force /etc/apache2/all.conf /etc/apache2/httpd.conf ;}
[[ "$1" = "restricted" ]] && { ln -s --force /etc/apache2/restricted.conf /etc/apache2/httpd.conf ;}
sudo systemctl restart httpd

And add execution permissions to it :

sudo chmod +x /path/to/your/script.sh

Now modify /etc/apache2/restricted.conf to filter requests by IP. You can find information on that here : https://httpd.apache.org/docs/2.4/es/mod/mod_authz_core.html#require

Now set the root cron as :

sudo crontab -e

And in there add this :

* 13 * * 1-5 /path/to/your/script.sh "all"
* 17 * * 1-5 /path/to/your/script.sh "restricted"

And be happy!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!