A8DOG

A8DOG

随便写写,记录折腾过程!
telegram

Want to play with a high-end server even if you don't have money? Linode's $100 credit is really awesome!

I also recently discovered Linodes and got $100 for free. I have been using it for a week now, so I'm writing an article to record my experience. You can also refer to it if you're interested!

Note: This article contains no advertisements, and our website will not display any ads! Here's a screenshot of the server running for 7 days.

Snipaste_2023-04-05_07-14-25

The server I set up is an AMD EPYC 7642 with 6 cores and 16GB RAM in a Japanese data center. Currently, it is running some scripts to process certain things.
It has been stable for 7 days, and I don't know how long it will remain stable or if I can fully utilize the $100 credit. I will update the specific situation below this paragraph if anything changes!

First of all, I bought an account and logged in directly with the account password. At that time, I planned to create a free server website through the API for everyone to play with, and the server would automatically be destroyed after 72 hours. However, my account got banned, probably because I logged in manually. But the login prompt said the account password was incorrect, so I felt that the vendor might have changed the password.

So I switched to another provider, which cost around 45-55 RMB. Then I found out that services like Amazon, Linodes, Vultr, etc., which can be used for free, can also be accessed through APIs to create servers. There are even websites specifically designed for creating servers.

Five-in-one panel for server management: https://cloud.bobu.me/ (Not an advertisement, I saw this in the product description when I bought the account from the second provider. It claims that using the API is more stable.)

Before buying Linodes from the second provider, I purchased a 32v free account from Amazon. The first time I used it, I didn't understand it well, so I logged in manually and the account got banned the next day.

Summary:#

Currently, the Linodes account I purchased for around 50 RMB has been stable for about a week, and I have earned back at least 50 RMB. To use the API panel, you need to pay a fee.

If you don't want to pay for the API panel, you can contact chatgpt and ask it to write a PHP file for opening Linodes API. Try to avoid logging in manually. Of course, a reliable account seller is also necessary. I always felt that the first account I bought had its password changed by the vendor.

In addition, the $100 credit from Linodes has a time limit, maybe three or two months. Don't hesitate to use it to create high-performance servers. This is mainly suitable for running unimportant scripts. It is not suitable for hosting websites or building a strong online presence, as you never know when it might go down. It's great for testing and experimenting. Currently, I have been running some things and the CPU usage is around 60%.

Experimentation Method#

If you have previously created servers through APIs and your Linodes account is stable, or if you have the energy to troubleshoot server issues that may cause traffic loss or SEO ranking problems, or if your scenario involves a fixed data CMS program and you want to save some money by sharing server computing power, you can try the method I describe below.

First, you need a spare server. There are many vendors offering discounted servers for activities.

Then install the happy version of Baota, because free is the happiest. For details, you can refer to my article Three Happy Versions of Baota - Free Baota Enterprise Edition with Communication Stripped.

Refer to my previous article A PHP File + Cloudflare for Failover! to configure some information and add monitoring. Deploy it on the spare server.

The download link for the code inside is invalid because I switched programs, but I will paste the complete code at the bottom.
You can install FTP storage + file synchronization in the Baota plugin and connect it to your spare server.

Or, if you have a movie and TV show website with no user data, only video data, you can definitely have a release page. You can add a Linodes domain on the release page and set up file synchronization from the source server to the Linodes server. This way, you can share the computing power!

As long as you don't lose your creativity, there are always more solutions than difficulties. There is always a way to apply things reasonably!

Failover Code:#

<?php
header('Content-type:application/json');

// Token obtained after creating the API, written after Bearer
$Authorization = 'Authorization: Bearer ';
// IP for ping check
$pingip='';
// Zone ID
$id = '';
// DNS record ID to be modified, set $get_dnsid to true to get the record list, set $get_dnsid to false after setting dnsid
$dnsid = '';
// Record type
$dnstype = 'A';
// Name
$dnsname = '';
// Modified IP
$dnscontent = '';
// Proxy
(bool)$dnsproxied = false;
// TTL
$dnsttl = 1;


// Get DNS record ID list, set to true to display JSON format DNS record list when accessing the PHP address.
$get_dnsid = false;

if ($get_dnsid === true) {
    // Get DNS ID
    $api_dnsid = 'https://api.cloudflare.com/client/v4/zones/' . $id . '/dns_records';
    try {
        $json = curl_get($api_dnsid, [$Authorization]);
        $json = json_decode($json);
        echo json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
    } catch (Exception $aaa) {
        $json = [
            'state' => 1,
            'msg' => 'API failed to get DNS ID'
        ];
        echo json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
    }
    exit();
} else {
    if (pingDomain($pingip, 443) === -1) {
        changeDNS($dnstype, $dnsname, $dnscontent, $dnsproxied, $dnsttl, $id, $dnsid, $Authorization);
    }
}

// Ping
function pingDomain($domain, $port)
{
    try {
        $starttime = microtime(true);
        $file      = fsockopen($domain, $port, $errno, $errstr, 10);
        $stoptime  = microtime(true);
        $status    = 0;

        if (!$file) $status = -1;  // Site is down
        else {
            fclose($file);
            $status = ($stoptime - $starttime) * 1000;
            $status = floor($status);
        }
        return $status;
    } catch (\Exception $a) {
        return false;
    }
}

// Modify DNS
function changeDNS($dnstype, $dnsname, $dnscontent, $dnsproxied, $dnsttl, $id, $dnsid, $Authorization)
{

    if ($dnsid != '') {
        $api = 'https://api.cloudflare.com/client/v4/zones/' . $id . '/dns_records/' . $dnsid;

        $json = [
            'type' => $dnstype,
            'name' => $dnsname,
            'content' => $dnscontent,
            'proxied' => $dnsproxied,
            'ttl' => $dnsttl,
        ];
        $json = json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
        $temp = curl_patch($api, [$Authorization], $json);
        $temp = json_decode($temp);
        echo json_encode($temp, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
    } else {
        $json = [
            'state' => 1,
            'msg' => 'DNS ID is empty, please set the DNS ID first'
        ];
        echo json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
    }
}


//--------------------------------------------------CURL
function curl_get($url, $header)
{

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    //curl_setopt($ch, CURLOPT_ENCODING,'gzip');

    $contents = curl_exec($ch);
    curl_close($ch);
    //$contents = mb_convert_encoding($contents, 'utf-8','GB2312');
    return $contents;
}
function curl_patch($url, $header, $data)
{

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    //curl_setopt($ch, CURLOPT_ENCODING,'gzip');

    $contents = curl_exec($ch);
    curl_close($ch);
    //$contents = mb_convert_encoding($contents, 'utf-8','GB2312');
    return $contents;
}
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.