GameServerManagers / LinuxGSM

The command-line tool for quick, simple deployment and management of Linux dedicated game servers.
https://linuxgsm.com
MIT License
4.32k stars 821 forks source link

fastdl module error #872

Closed JimTR closed 8 years ago

JimTR commented 8 years ago

I have been trying to use the fastdl module however I get problems with it . the problem is the fastdl folder it is hard coded to {$rootdir}/www assuming the folder needs to be resolvable quite a few web servers place there public facing code in a folder under the users root directory called public_html example : /home/jimr/public_html/fastdl could resolve to http://mydomain.com/fastdl.

if the fastdl folder needs to be resolvable over the web you may want to check the apache or nginx setup files for the user for where the resolvable folder is (document root) these on apache2 are located in /etc/apache2/sites-enabled and are normally named something like mydomain.com.conf. so calling awk '$1~/^DocumentRoot/{print $2}' /etc/apache2/sites-enabled/mydomain.com.conf will return something like

/home/gamer/public_html.

doing it this way relies on knowing the domain name but does give the resolvable folder the same is true if you set up a sub domain you may get a response like

/home/gamer/domains/player.mydomain.com/public_html.

dependant on where the doc root for the sub domain is. If fastdl folder does not have to be resolvable ignore this

UltimateByte commented 8 years ago

Did you read this ? https://github.com/dgibbs64/linuxgsm/wiki/FastDL

UltimateByte commented 8 years ago

FastDL has to be resolvable. But it's still the user that has to setup his server accordingly. It's intended to work with usermod or with manual virtual hosts. For now, garry's mod is the only supported game.

JimTR commented 8 years ago

that was what is was playing with but it is hard coded to www, so the user has to edit the module to reflect where the actual files are located ... tools such as Plesk or Virtualmin can take the problems of creating apache vhosts (configuring everything correctly for you) but do tend to use public_html are the doc root. I added the issue because I read

!'m no web admin.

so using Virtualmin (share/freeware) may be a lot easier to use than manually setting up a lamp stack and learning how to use it as Virtualmin does most of the work for you
example Vitrtualmin apache directives

<VirtualHost *:80> SuexecUserGroup "#1003" "#1003" ServerName mydomain.com ServerAdmin service@mydomain.com ServerAlias www.mydomain.com ServerAlias webmail.mydomain.com ServerAlias admin.mydomain.com ServerAlias autoconfig.mydomain.com DocumentRoot /home/gamer/public_html ErrorLog /var/log/mydomain.com_error_log CustomLog /var/log/mydomain.com_access_log combined ScriptAlias /cgi-bin/ /home/gamer/cgi-bin/ ScriptAlias /awstats/ /home/gamer/cgi-bin/ ScriptAlias /AutoDiscover/AutoDiscover.xml /home/gamer/cgi-bin/autoconfig.cgi ScriptAlias /Autodiscover/Autodiscover.xml /home/gamer/cgi-bin/autoconfig.cgi ScriptAlias /autodiscover/autodiscover.xml /home/gamer/cgi-bin/autoconfig.cgi DirectoryIndex index.html index.htm index.php index.php4 index.php5 <Directory /homegamer/public_html> Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch Require all granted AddType application/x-httpd-php .php AddHandler fcgid-script .php AddHandler fcgid-script .php5 FCGIWrapper /home/gamer/fcgi-bin/php5.fcgi .php FCGIWrapper /home/gamer/fcgi-bin/php5.fcgi .php5 <Directory /home/gamer/cgi-bin> allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch Require all granted RewriteEngine on RewriteCond %{HTTPHOST} =webmail.mydomain.com RewriteRule ^(.) https://mydomain.com:20000/ [R] RewriteCond %{HTTPHOST} =admin.mydomain.com RewriteRule ^(.) https://mydomain.com:10000/ [R] RemoveHandler .php RemoveHandler .php5 php_admin_value allow_url_fopen On php_admin_value engine Off IPCCommTimeout 31 FcgidMaxRequestLen 1073741824

AuthName "mydomain.com statistics" AuthType Basic AuthUserFile /home/gamer/.awstats-htpasswd require valid-user

PerlRequire /etc/webmin/virtualmin-google-analytics/apachemod.pl

PerlOutputFilterHandler Virtualmin::GoogleAnalytics

<Location /git> DAV on AuthType Basic AuthName gamer.mydomain.com AuthUserFile /home/gamer/etc/git.basic.passwd Require valid-user Satisfy All RedirectMatch ^/git$ http://gamer.mydomain.com/git/gitweb.cgi RedirectMatch ^/git/$ http://gamer.mydomain.com/git/gitweb.cgi RewriteEngine off AddHandler cgi-script .cgi RedirectMatch /cgi-bin/mailman/([^/.])(.cgi)?(.) https://mydomain.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 RedirectMatch /mailman/([^/.])(.cgi)?(.) https://mydomain.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3 Alias /pipermail /var/lib/mailman/archives/public Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi .

above is an average virtualmin conf file overwriting this with your simplified conf file could screw up loads of options that are set, in this example, by Virtualmin or by Plesk, my thought was for the script to find out what has been set and use it rather than overwriting the file. That said with customers I host I don't allow write access to those files so they are not editable, so no chance of changing them. So the user will have to edit the module.

UltimateByte commented 8 years ago

I can rename wwwto public_htmlif you think it's more standard. I don't wish to move away files from the user though. LGSM has a philosophy of "everything inside the user folder" which i like and don't wish to change.

Virtualmin and Plesk users are not really my problem. I don't think LGSM is meant for them though. A LAMP server isn't required, Apache2 is enough. Take 2 minutes to install and setup.

apt-get install apache2
nano /etc/apache2/sites-available/mywebsite.conf
# paste, edit stuff and save
a2ensite mywebsite
service apache2 reload

Done

JimTR commented 8 years ago

I am thinking of the web interface here as it will need php & mysql enabled to work hence the lamp stack.
So I guess as things are the only place you can use this is either on a home pc that is acting as web/game server or an unmanaged VPS unless I have missed something. home pc option could run into DNS problems as the domain name really does need a static IP & certain ISP's may not allow you to open ports on the supplied router etc. etc. unmanaged VPS you may need to run bind to propagate the DNS records.

I don't quite get this :-

LGSM has a philosophy of "everything inside the user folder" which i like and don't wish to change.

if you look at the example the user name is gamer and all references point to that users home folder.

cedarlug commented 8 years ago

Is there a reason why a simple simlink public_html -> www doesn't solve the problem?

UltimateByte commented 8 years ago

Yup, we can even change "www" to "public_html" into the code's variable if that helps. I prefer "www" than "public_html" just because i'm used to work like that, but public_html is more standard.

JimTR commented 8 years ago

Cool, another point I noticed when the module sets up it makes the folder under where the script is located, this may not be the users home folder ... I, for example, have the following for most users, where the game servers are installed under the games folder then game name, and public_html is located in the root, this approach stops http connections direct access to the game servers folders . perhaps consider adding the www/public_html folder to the users root rather than under the game root, also the user may want to add other content to www/public_html (forum or something) and it may be a bit messy having the web root folder nested in the game root folder. In the example below this user has 3 games installed, you could create 3 virtual hosts pointing to 3 folders under each game root (I know the example games do not all support fastdl it is an example) or just have all the web content under 1 folder split by game e.g ~/public_html/gmod/fastdl and ~/public_html/fof/fastdl etc. this means 1 virtual host per user rather than 3

Sample users home folder . ├── games │   ├── css │   ├── fof │   └── gmod ├── Maildir │   ├── cur │   ├── new │   └── tmp ├── perl5 │   ├── lib │   └── man ├── public_html └── Steam ├── appcache ├── config ├── depotcache ├── logs ├── steamapps └── userdata notes on above: Maildir email folder is there if you configure postfix to store user email in the users root rather than postfix's std which is /var/mail. This folder can be ignored along with the perl5 folder this is my dev user and am playing with perl web apps rather than php to see if there is an advantage using perl

With the www/public_html folder being nested a few folders deep I guess you have to give the apache user (default www-data) access to the users root folder ? As without granting www-data permissions to the folders above the public_html/www folder apache may throw a forbidden error as the apache user does not have access to them. To fix this you could change the apache user to the same user as the game server user. This leads me on to if you have 2 games, that support fastdl, running as 2 different users, if you have changed the apache user to match the user of game 1 the user of game 2 will not be able will not be able to use the fastdl module as the apache user is the wrong user !

To fix that point perhaps you need to point out that when setting up apache you could use suEXEC to allow different users to be the apache user to do this make sure suEXEC is installed and enabled in apache and add the required user & group id to the host file . example Directive :- SuexecUserGroup "#1003" "#1003" this sets userid/groupid 1003 to be the apache user for say the web space me.domain.com, if you have a second game set up for fastdl under a different user just change the directive to the correct unix user in the hosts file.

@cedarlug I don't like using symlinks in any web space they do work, but some clever hackers may be able to use a symlink to gain access to parts of the server they should not.

UltimateByte commented 8 years ago

Got no time to read the whole thing now, gotta go play some music, but LGSM currently doesn't have a variable with the game's name. So yeah, it'd be cool to have ~/public_html/servername/fastdl but i see no way of doing it without a code rework.

JimTR commented 8 years ago

you do have a servicename & gamename defined in the server script (gmod this is the LGSM script I am basing it on) perhaps you could use one of those ? I would use the servicename just in case someone runs more than one server on the same install. enjoy listening to Led Zep :smile:

UltimateByte commented 8 years ago

What if a user has two server for the same game ? We can use the port, but what if a user changes his server's ports ? :o)) Say i got 8 gmod servers (true story, fuck my life), it happened in the past that i reorganized ports. We got no unique ID per server, that's the issue.

I play the drums, and sorry for the deception but i don't like Led Zep very much (and i've been blamed enough about that, don't worry) :p

JimTR commented 8 years ago

ah I see ... never thought of reorganising the ports do people do this often ? oh well perhaps we need one (unique id) perhaps the server run filename basename "$0" :smile:

UltimateByte commented 8 years ago

Maybe a little file in lgsm folder ?

JimTR commented 8 years ago

whichever you think

UltimateByte commented 8 years ago

Renamed to public_html Won't change to a more advanced foldername than the one set currently as it wouldn't fit current LGSM's policy. However, if you wish to change it in your fork, it's quite easy, as the destination folder is set in two variables : https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/functions/command_fastdl.sh#L15

webdir="${rootdir}/public_html"
fastdldir="${webdir}/fastdl"

You can add any LGSM's variable that you wish. Port, servicename, and so on.

lock[bot] commented 6 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.