webbukkit / dynmap

A set of Minecraft mods that provide a real time web-based map system for various Minecraft server implementations.
https://www.reddit.com/r/Dynmap/
Apache License 2.0
2.05k stars 418 forks source link

Questions about having a separate webserver #1978

Closed wioxjk closed 4 years ago

wioxjk commented 8 years ago

Hi

I am want to run dynmap on a separate physical webbserver ( I have a few of thoose ). Every server is on the same local network and I want to run the dynmap on my main webbserver. I am storing the map in a mySQL database on the webbserver ( separate from the minecraftserver )

Is it possible?

TonyGravagno commented 6 years ago

I'm also now facing this question with a similar but different scenario: I host Minecraft and dynmap data generation in a hosted environment (MCProHosting). I've migrated to MySQL which is hosted in a completely different remote environment. I don't mind the outbound update traffic. The dynmap webserver is currently running on the game server, requiring data to get pulled back in from the remote system.

I want to hit a remote webserver and get that to access MySQL so that I do not have to run this webserver component at all in the game server.

I have not found any clear instructions for doing this and request that someone who has done this post it here or in the GitHub wiki. If we can just get some rough instructions to follow here, I'll translate that into a pretty HowTo for the wiki.

Note again that we already have a remote website with access to MySQL. Dynmap needs to interface between the database and the webserver, in this role it does not need to serve as a webserver.

Thanks.

jwshields commented 6 years ago

That is very possible. You could go a number of routes.

To clarify, bukkit/spigot on box a, and dynmap connects to mysql on box b is that correct? Is this behind a NAT'd network? Do you have access to setting port forwarding rules?

From there I would suggest installing nginx (or your choice of webserver) + php-fpm on box b Copy the files from box a [mc root]/plugins/dynmap/web/ onto box b into wherever your web server puts the web content (generally /var/www/html/)

Set up nginx and php like normal, create a site, install and configure certbot/letsencrypt, set up nginx to host the site, put the dynmap web files into your html folder. Verify that nginx is serving content in general.

If you're running a dual stack network behind nat, set your ipv6 address (ie minecraft.example.com) to the ip of the webserver, and the ipv4 for it (minecraft.example.com) to the NAT/external address.

start the game and make sure/get dynmap writing to the database. (I forget/don't know how dynmap does the web files, but they might be regenerated on start? if so, copy the standalone directory to the webserver)

If dynmap is writing to the DB, you're good; check the site and see if content is being served properly. if not, the standalone config might be broken in a way.

Give me a few more minutes and I'll type out & share my config in detail

jwshields commented 6 years ago

I just realized how old @wioxjk 's post was.

@TonyGravagno in the configuration.txt for dynmap, just put in the mysql details for the other node hosting the DB, and make sure that DB is configured to listen and allow connections on interfaces other than localhost. There are a few guides posted in the wiki, and I've made a few issue tickets to request adding information to the wiki Please read these. https://github.com/webbukkit/dynmap/issues/2026 https://github.com/webbukkit/dynmap/issues/2027

TonyGravagno commented 6 years ago

Confirmations:

Server 3 is a common shared host, Apache already running. I've copied the entire dynmap tree from the MC server 1 to that server. I can navigate to http://subdomain.mydomain.tld/dynmap/web and it loads index.htm and related .js files. But I'm getting the common black screen, and here is where it gets complex.

I do not have the code in front of me so am being a bit vague for now....

1) There is no generated config.js, so that data is not available in map.js when required. So I queried the working dynmap web server on the MC server, and copied the config.js that was generated and returned to the browser. I then saved this in the new server 3 under web/standalone.

2) The map.js code keeps dying with the error that config isn't defined. So I'm trying to follow the trail to see how/where config is defined.

3) The config.js refers to /up/files, but the files are PHP programs that are in /standalone. Not knowing the root of where it's trying to retrieve files, I've been experimenting with changing that to /dynmap/web/standalone/x, standalone/x, etc

4) It's not clear where it's trying to read config data from. The .js code is looking for "configuration", not "configuration.txt". I copied /dynmap/configuration.txt to /dynmap/web/up/configuration. Still getting the error that config wasn't defined I also copied to /dynmap/web/standalone.configuration.

5) About configuration.txt on this server 3: a) I understand that most of the details here are used on the MC server, not by a system that is not accessing Minecraft. I don't see a setting in here that says "this is a standalone server, don't try to access Minecraft". b) tilespath is still the default 'web/tiles'. c) webpath is still 'web' but I don't know if that's relative to /dynweb/web where index.html is found, or to /dynweb, or to http://mysite/ root. d) Just in case I've commented out webserver-port 38123. I know the dynmap web server isn't running and that it's not binding to that port, but I don't know (don't think so) if it's still using this value anywhere for building URLs for client use. The default port on this common server is 80. a) I don't need to modify the MySQL setting for this as this system 3 has ready access to that server. b) I've tried disable-webserver as both true and false. It's not clear if that's used to disable functionality even when this code is serving PHP on an underlying server. c) In the url array (and where I believe it should get those values that it says it doesn't have) I've been experimenting with changes like: configuration: "standalone/configuration" configuration: "up/configuration" I have changed other values like "standalone/sendmessage". d) Even though tiles are now in MySQL I left tiles and markers set to "tiles/" because there are other folders under there. e) I have not set verbose mode to true yet - it doesn't seem to be reading this config data at all.

6) There was a hard-coded reference to a hostname or port in one of the code items, forgot where for now. I changed that to my new system 3 host.

7) I have not yet checked PHP error logs - I can run anywhere from PHP 5.6 to 7.1 if required.

So unless I'm over-thinking this, this is Not quite the slam-dunk easy setup that it could be. I'm really hoping we can get through this and create a HowTo for this.

Thanks!!

wioxjk commented 6 years ago

Hi again :) I did solve this with apache reverse proxy, it worked great! I did write about this on serverfault:

https://serverfault.com/questions/799012/dynmap-throu-mod-proxy-on-a-external-webserver

jwshields commented 6 years ago

If you've solved this, could you please close the ticket?