Jump to content

Nginx + CloudFlare to Multi Theft Auto External Download


Carlos Dorelli
 Share

Recommended Posts

Hello, I'm here today to share a script very helpful that I've been using for years on my company. This script uses nginx to make the download easier and faster to Multi Theft Auto servers and it's totally automated to TCAdmin. This help a lot of people like me that the internet is horrible (really horrible) to download faster the server mods and be happy playing on it¬†ūüôā

Watch it working

Prerequisites

  1. Have nginx installed on the machine (I'm using port 8080 but you can use any other if you want. Just make sure to change the ports on the script).
  2. Have a domain on CloudFlare (we are going to use it to add a DNS redirect to the machine IP. Without it won't work anyway).
  3. Have a Multi Theft Auto Game Config (if you don't just download this one that already have the scripts. The credits of it goes to @LFA, I've just added the scripts on it. Don't forget to change with your domain and ports).

Installation
CloudFlare

  1. Log in on CloudFlare
  2. Select the domain you want to use it
  3. Go to DNS
  4. And add a Record A  pointing to your machine IP keeping the Proxy Status as "DNS Only"
    Screenshot_93.thumb.png.f6fd9869da49d58a718b5fd0d8de9f4e.png
  5. Save

Adding and modifying the scripts

  1. Go to Settings > Games & Other Voice Servers > Multi Theft Auto (or the name of the game in your config) > Custom Scripts > New
  2. FIRST SCRIPT | Operating System: Windows | Script Engine: Batch file/shell script | Event: After created | Description: Faster Download | Order: 0 | Check "Ignore execution errors"
     
    cd C:\nginx\
    echo server {  > "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         listen 8080;  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         server_name %ThisService_GameId%%ThisService_ServiceId%.cpa.timberhost.com.br;  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         location / {  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         root "C:/TCAFiles/Users/%ThisService_UserNameLowerCase%/%ThisService_ServiceId%/mods/deathmatch/resource-cache/http-client-files/";  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         autoindex on;  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         }  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo } >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    cd /nginx
    taskkill /f /IM nginx.exe
    start nginx
    
    EXIT

    Obs: 8080 is the port that will be used by nginx (change if you want to use another port). Change "cpa.timberhost.com.br" for "cpa.yourdomain.com" (the domain added on the CloudFlare before).

    ---
    SECOND SCRIPT | Operating System: Windows | Script Engine: Batch file/shell script | Event: After deleted| Description: Delete Compacted Download | Order: 0 | Check "Ignore execution errors"
     
    del /f /q C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf

    ---
    THIRD SCRIPT | Operating System: Windows | Script Engine: Batch file/shell script | Event: Custom action | Description & Name: Faster & Compacted Download | Order: 0 | Check "Ignore execution errors" (this part you can configure as you want).
     
    taskkill /f /IM nginx*
    del /f /q C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf
    cd C:\nginx\
    echo server {  > "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         listen 8080;  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         server_name %ThisService_GameId%%ThisService_ServiceId%.cpa.timberhost.com.br;  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         location / {  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         root "C:/TCAFiles/Users/%ThisService_UserNameLowerCase%/%ThisService_ServiceId%/mods/deathmatch/resource-cache/http-client-files/";  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         autoindex on;  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo         }  >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    echo } >> "C:\nginx\conf\%ThisService_GameId%%ThisService_ServiceId%.conf"
    start nginx
    echo '%ThisService_GameId%%ThisService_ServiceId%.cpa.timberhost.com.br'
  3. Now go the Configuration Files > mtaserver.conf (if you don't have this file on it add because it's very important) > Template > In "<httpdownloadurl></httpdownloadurl>" and change by "<httpdownloadurl>http://$[Service.GameId]$[Service.ServiceId].yourdomain.com:YOURNGINXPORT</httpdownloadurl>". Now save and be happy ūüėĀ

Final considerations
If this tutorial helped you please leave a like on the topic. If you have any problem and need help with it just contact me here on the comments or on Discord (Eldremor#0001).

Edited by CarlosDorelli
Link to comment
Share on other sites

  • 10 months later...
  • 5 weeks later...
On 02/01/2022 at 11:28, Daniel149 said:

Não tá funcionando eu estalei tudo certinho 

It didn't work with me either, @Eldremor installed it with me, but it wasn't successful after a while we didn't talk anymore, but since then I'm trying to solve it myself.

Link to comment
Share on other sites

  • 5 weeks later...
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use