Jump to content
  • 0

Cronjob With Https


Blesta Addons

Question

i want to run cronjob with https . my actual cron is 

*/5 * * * * /usr/bin/php /home/xxxxxxx/public_html/index.php cron

i have a custom cron that need to be run in https version , i have a model that need to check for https and the server host

$this->base_url = "http" . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] != "off" ? "s" : "") . "://" . (isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : nul) . "/";

this code always generate a http with empty server 

http:///

i have tweked it to be

$this->base_url = "http" . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] != "off" ? "s" : "") . "://" . (isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $system_company->hostname) . "/";

but i still need to check http or https as every protocol has a defirenet function to run .

 

 

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I'm guessing this isn't the answer you're looking for, but in the off chance -

/usr/bin/wget -q https://www.yourdomain.com/blesta/cron/?cron_key=CRONKEY >/dev/null 2>&1

If you're trying to determine whether the cron is being accessed via HTTPS or not, you will not be able to determine this via CLI. If you execute your cron in the manner mentioned above, then the $_SERVER["HTTPS"] global should be present. Just not via CLI.

Link to comment
Share on other sites

  • 0

I am confused by this whole post.

 

i want to run cronjob with https . my actual cron is 

*/5 * * * * /usr/bin/php /home/xxxxxxx/public_html/index.php cron

What is wrong with the above setup? It does not use http or even https -- looks secure to me.

 

-Adam

Link to comment
Share on other sites

  • 0

The cron is running in http mode nad not https .

The cronjob you posted above:

i want to run cronjob with https . my actual cron is 

*/5 * * * * /usr/bin/php /home/xxxxxxx/public_html/index.php cron

Does not use http or even https. So I am confused to what you are saying. What is your question / issue?

Thanks,

-Adam

Link to comment
Share on other sites

  • 0

The question is very clear . How to make the cronjob run in https mode rather than normal mode http .

This question actually doesn't make sense. Cron has nothing to do with HTTP/S. Cron is a job scheduler, it doesn't care what your script does and it has nothing to do with any protocol. So there is no https or http mode for cron. The problem is either with PHP or your webserver.

 

It's difficult to help since I don't understand what your script is supposed to do.

 

 

i have a model that need to check for https and the server host

$this->base_url = "http" . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] != "off" ? "s" : "") . "://" . (isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : nul) . "/";

It looks like you're reading headers from a remote request.  Where is this request coming from? Is it coming from a load balancer? Load balancers will sometimes move the variable you're looking for into a different header. Depending on your webserver you may have to check if the connection is over port 443.

 

Also, try checking if the $_SERVER["HTTPS"] is not empty rather than isset.

Link to comment
Share on other sites

  • 0

I'm guessing this isn't the answer you're looking for, but in the off chance -

/usr/bin/wget -q https://www.yourdomain.com/blesta/cron/?cron_key=CRONKEY >/dev/null 2>&1
 
If you're trying to determine whether the cron is being accessed via HTTPS or not, you will not be able to determine this via CLI. If you execute your cron in the manner mentioned above, then the $_SERVER["HTTPS"] global should be present. Just not via CLI.

Thanks Paul, that is what i'm searching .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...