Noctem/Monocle

Web server cannot load assets from reverse-proxy subdirectory

Opened this issue · 1 comments

From discord:

dneal12 (Dan) - Last Tuesday at 8:02 AM
For some reason, no matter what I do, whether I use Apache or nginx, no matter how simple I make the nginx config, I can't get icons on my map. When I access it from ip:port, everything renders fine. But when I use nginx to reverse proxy, no icons whatsoever..... Any help?
All I get is a map with no icons, no scan area, no gyms, etc.

dneal12 (Dan) - Last Tuesday at 8:21 AM
I mean the front end works as intended when I access it at ip:port
So I don't think that is it. It only renders the map and no icons when I go to mysite.xyz
My nginx conf:

server {
    listen 80;
    server_name mysite.xyz;
    location /map/ {
       proxy_pass http://127.0.0.1:5000/;
    }
}

Doesn't get much simpler than that
I fixed it
It did not like being at /map/, and was looking in the wrong place for assets and data. Once I changed location to / , it works

Speaking of reverse proxy, I use is to run a handful of monocole instances that can be referenced from a single source. The shared localStorage is great for filtering. And it allows for cross-domain calls to be masked away.

To cut back on loading, I also moved the icons/images to a base directory and made sure all the main.js files pointed to the correct path.
I used IIS for it:

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Reverse Proxy to Instance1" stopProcessing="true">
        <match url="^mdt1/(.*)"/>
        <action type="Rewrite" url="http://localhost:5000/{R:1}"/>
      </rule>
  	<rule name="Reverse Proxy to Instance2" stopProcessing="true">
        <match url="^mdt2/(.*)"/>
        <action type="Rewrite" url="http://localhost:5001/{R:1}"/>
      </rule>
    </rules>
    <outboundRules>
      <rule name="Add application prefix" preCondition="IsHTML">
        <match filterByTags="A" pattern="^/(.*)"/>
        <conditions>
          <add input="{URL}" pattern="^/(mdt1|mdt2)/.*"/>
        </conditions>
        <action type="Rewrite" value="/{C:1}/{R:1}"/>
      </rule>
      <preConditions>
        <preCondition name="IsHTML">
          <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"/>
        </preCondition>
      </preConditions>
    </outboundRules>
  </rewrite>
</system.webServer>