How to Log httpS?

Php Gurus,

I added a url logger to Mini Proxy so that whatever my free users browse gets logged into my db under their account usernames. The code of Mini Proxy is too long to fit into this post and so you may check it out here:

Using the Mini Proxy, whatever I browse now gets logged into my DB. Tbl: browsing_history. Columns: ids, time & dates, usernames, urls.

Now, when I view a url it gets logged.

// Dump $url into db

$stmt = mysqli_prepare($conn, "INSERT INTO 
browsing_histories(ids,usernames,urls) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($stmt, 'iss', $id, $user, $url);
mysqli_stmt_execute($stmt);
if($stmt)
{
    echo "Logged $url to db a success!";
}
else    
{
    echo "Logging $url to db failed!";
}

Q1. Why is the web proxy php script only fetching "http" but not "https" pages ? Which line to change and to what to fix this ? I get error: Error: The requested URL was disallowed by the server administrator.

If you check the link for the code then you will see that error is mentioned on line 308 on the script code.

Q2. I want to fake the REFERRER so the websites (viewed via the proxy) see the referrer as: and not the actual referrer. On which line do I add what lines of code to achieve this ?

1 Answer

A1: What values you have in $whitelistPatterns? There is url checking by preg_match.

If you don't want to restrict traffic, then remove this security condition.

This may also be due to the fact that you do not have valid root certificates on the server or incorrect time configuration. You can fix it on your server, or ignore this:

      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

A2: Insert between lines 110-172:

curl_setopt($ch, CURLOPT_REFERER, ');

Any line that isn't in a condition / block will be good. It should not matter. Although curl_setopt($ch, CURLOPT_HTTPHEADER, $curlRequestHeaders); set referer if this is present in the header. So before this line should be the default referrer and after: overridden. (I don't know if CURLOPT_REFERER has a higher priority thanreferer in CURLOPT_HTTPHEADER)

9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest