2

My setup consist of two servers, one for hosting websites and one for doing the heavy lifting (for example Minecraft). I am using Spigot to power some plugins and one of the plugins is dynmap (which is a interactive map for showing the world and the players online). More information regarding the dynmap is here: https://github.com/webbukkit/dynmap

Anyway, I want to use a ReverseProxy on my web server and Proxy the dynmap content so I can close some ports on the router. Currently I have just made a Port forward on port 8123 to my Minecraft server.

On the web server I am currently running Apache 2.4 and I have installed mod_proxy and mod_proxy_html. I have also defined this in the vhost file for both HTTP and HTTPS:

ProxyRequests off
ProxyPass "/map" "http://192.168.2.31:8123/"
ProxyPassReverse "/map" "http://192.168.2.31:8123/"

This should be rather self explanatory. But when I access the page [WEBSITE]/map I am greeted with a white blank page. I am getting this though:

<!DOCTYPE html>
<html lang="en">
<head>

    <title>Minecraft Dynamic Map</title>

    <meta charset="utf-8" />
    <meta name="keywords" content="minecraft, map, dynamic" />
    <meta name="description" content="Minecraft Dynamic Map" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <!-- These 2 lines make us fullscreen on apple mobile products - remove if you don't like that -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />   

    <link rel="icon" href="images/dynmap.ico" type="image/ico" />

    <script type="text/javascript" src="js/jquery-1.11.0.js?_=2.3-2074"></script>
    <link rel="stylesheet" type="text/css" href="css/leaflet.css?_=2.3-2074" />
    <script type="text/javascript" src="js/leaflet.js?_=2.3-2074"></script>

    <script type="text/javascript" src="js/custommarker.js?_=2.3-2074"></script>

    <script type="text/javascript" src="js/dynmaputils.js?_=2.3-2074"></script>

    <!--<link rel="stylesheet" type="text/css" href="css/embedded.css" media="screen" />-->
    <link rel="stylesheet" type="text/css" href="css/standalone.css?_=2.3-2074" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/dynmap_style.css?_=2.3-2074" media="screen" />
    <!-- <link rel="stylesheet" type="text/css" href="css/override.css" media="screen" /> -->

    <script type="text/javascript" src="version.js?_=2.3-2074"></script>
    <script type="text/javascript" src="js/jquery.json.js?_=2.3-2074"></script>
    <script type="text/javascript" src="js/jquery.mousewheel.js?_=2.3-2074"></script>
    <script type="text/javascript" src="js/minecraft.js?_=2.3-2074"></script>
    <script type="text/javascript" src="js/map.js?_=2.3-2074"></script>
    <script type="text/javascript" src="js/hdmap.js?_=2.3-2074"></script>
    <script type="text/javascript" src="standalone/config.js?_=2.3-2074"></script>

    <script type="text/javascript">
            $(document).ready(function() {
                window.dynmap = new DynMap($.extend({
                    container: $('#mcmap')
                }, config));
            });
    </script>

</head>
<body>
<noscript>
 For full functionality of this site it is necessary to enable JavaScript.
 Here are the <a href="http://www.enable-javascript.com/" target="_blank">
 instructions how to enable JavaScript in your web browser</a>.
</noscript>

    <div id="mcmap"></div>
</body>
</html>

I have also defined the web server as "trusted proxy" in the dynmap config. So my guess is that JavaScript or pictures is blocked somehow? mod_security is not installed.

EDIT

The links appears as 404, I should propably add sublinks in the proxy

404

EDIT 2

Alright, so I added those lines into the vhost config, and now I am getting far less errors, that's something.

        ProxyRequests off
    ProxyPass "/map"                "http://192.168.2.31:8123/"
    ProxyPass "/js"                 "http://192.168.2.31:8123/js/"
    ProxyPass "/js/minecraft"       "http://192.168.2.31:8123/js/minecraft/"
    ProxyPass "/js/map"             "http://192.168.2.31:8123/js/map/"
    ProxyPass "/css"                "http://192.168.2.31:8123/css/"
    ProxyPass "/standalone"         "http://192.168.2.31:8123/standalone/"

    ProxyPassReverse "/map"         "http://192.168.2.31:8123/"
    ProxyPassReverse "/js"          "http://192.168.2.31:8123/js/"
    ProxyPassReverse "/js/minecraft""http://192.168.2.31:8123/js/minecraft/"
    ProxyPassReverse "/js/map"      "http://192.168.2.31:8123/js/map/"
    ProxyPassReverse "/css"         "http://192.168.2.31:8123/css/"
    ProxyPassReverse "/standalone"  "http://192.168.2.31:8123/standalone/"

I am still trying to figure out why the servers does'nt send me the .js files that are located under / (see picture)

enter image description here

EDIT 3

Alright, this is rather strange. But if I remove the last backslash like this, I am not getting a 404 on the -js file in the catalogue /standalone.

 ProxyPass "/standalone"  "http://192.168.2.31:8123/standalone"
 ProxyPassReverse "/standalone"  "http://192.168.2.31:8123/standalone"

enter image description here

EDIT 4

Alright, some progress at least. Editing those lines like I did on previous edit did give me a lot of more 404, but this time it was from the tiles and images. So that is good.

 ProxyPass "/up/configuration"   "http://192.168.2.31:8123/up/configuration"
 ProxyPassReverse "/up/configuration"   "http://192.168.2.31:8123/up/configuration"
halfer
  • 161
  • 1
  • 5
  • 25
Orphans
  • 1,396
  • 2
  • 18
  • 30

2 Answers2

1

You should really check the URI mapping rules for proxy requests. And overall prefer <Location> to handle proxied content. Also note the ProxyPassReverse directive in Apache, as well as dynmap configuration for its web resource locations. By default, it is using relative paths, so that all you should've done is

<Location "/map/"> ProxyPass http://192.168.2.31:8123/ </Location> Just note that in such configuration your map will be dependent on the server being online.

AnrDaemon
  • 261
  • 2
  • 6
0

Alright, after several hours of trial and error. And alot of different eyes that took a look I finally came up with a config that looked like this:

    ProxyRequests off
    ProxyPass "/map"                "http://192.168.2.31:8123/"
    ProxyPass "/js"                 "http://192.168.2.31:8123/js/"
    ProxyPass "/js/minecraft"       "http://192.168.2.31:8123/js/minecraft/"
    ProxyPass "/js/map"             "http://192.168.2.31:8123/js/map/"
    ProxyPass "/css"                "http://192.168.2.31:8123/css/"
    ProxyPass "/standalone"         "http://192.168.2.31:8123/standalone"
    ProxyPass "/up/configuration"   "http://192.168.2.31:8123/up/configuration"
    ProxyPass "/version.js"         "http://192.168.2.31:8123/version.js"
    ProxyPass "/images"             "http://192.168.2.31:8123/images/"
    ProxyPass "/tiles/world/t"      "http://192.168.2.31:8123/tiles/world/t"
    ProxyPass "/tiles/world/t_day"  "http://192.168.2.31:8123/tiles/world/t_day"
    ProxyPass "/tiles/world_nether/nt"      "http://192.168.2.31:8123/tiles/world_nether/nt"
    ProxyPass "/tiles/world_nether/flat"      "http://192.168.2.31:8123/tiles/world_nether/flat"
    ProxyPass "/tiles/world_the_end/st"      "http://192.168.2.31:8123/tiles/world_the_end/st"
    ProxyPass "/up/world/world"     "http://192.168.2.31:8123/up/world/world"
    ProxyPass "/up/world/world_nether"     "http://192.168.2.31:8123/up/world/world_nether"
    ProxyPass "/up/world/world_the_end"     "http://192.168.2.31:8123/up/world/world_the_end"
    ProxyPass "/mapimages"          "http://192.168.2.31:8123/mapimages/"
    ProxyPass "/tiles/_markers_"    "http://192.168.2.31:8123/tiles/_markers_"
    ProxyPass "/tiles/faces/16x16"  "http://192.168.2.31:8123/tiles/faces/16x16"
    ProxyPass "/tiles/faces/32x32"  "http://192.168.2.31:8123/tiles/faces/32x32"

    ProxyPassReverse "/map"         "http://192.168.2.31:8123/"
    ProxyPassReverse "/js"          "http://192.168.2.31:8123/js/"
    ProxyPassReverse "/js/minecraft""http://192.168.2.31:8123/js/minecraft/"
    ProxyPassReverse "/js/map"      "http://192.168.2.31:8123/js/map/"
    ProxyPassReverse "/css"         "http://192.168.2.31:8123/css/"
    ProxyPassReverse "/standalone"  "http://192.168.2.31:8123/standalone"
    ProxyPassReverse "/up/configuration"            "http://192.168.2.31:8123/up/configuration"
    ProxyPassReverse "/version.js"  "http://192.168.2.31:8123/version.js"
    ProxyPassReverse "/images"             "http://192.168.2.31:8123/images/"
    ProxyPassReverse "/tiles/world/t"             "http://192.168.2.31:8123/tiles/world/t"
    ProxyPassReverse "/tiles/world/t_day"             "http://192.168.2.31:8123/tiles/world/t_day"
    ProxyPassReverse "/tiles/world_nether/nt"      "http://192.168.2.31:8123/tiles/world_nether/nt"
    ProxyPassReverse "/tiles/world_the_end/st"      "http://192.168.2.31:8123/tiles/world_the_end/st"
    ProxyPassReverse "/up/world/world"   "http://192.168.2.31:8123/up/world/world"
    ProxyPassReverse "/up/world/world_nether"     "http://192.168.2.31:8123/up/world/world_nether"
    ProxyPassReverse "/up/world/world_the_end"     "http://192.168.2.31:8123/up/world/world_the_end"
    ProxyPassReverse "/mapimages"          "http://192.168.2.31:8123/mapimages/"
    ProxyPassReverse "/tiles/_markers_"    "http://192.168.2.31:8123/tiles/_markers_"
    ProxyPassReverse "/tiles/faces/16x16"  "http://192.168.2.31:8123/tiles/faces/16x16"
    ProxyPassReverse "/tiles/faces/32x32"  "http://192.168.2.31:8123/tiles/faces/32x32"

This works (in my case), but I know that I have to redefine all rules if there is a change in the catalogue structure. Everything works as I should with this config.

Just change the world names if your is diffenrent.

I would also recommend any reader to try "AnrDaemons" suggestion

Orphans
  • 1,396
  • 2
  • 18
  • 30