openstreetmap / mod_tile

Renders map tiles with mapnik and serves them using apache
http://wiki.openstreetmap.org/wiki/Mod_tile
GNU General Public License v2.0
288 stars 190 forks source link

merging per-server and per-virtualhost config is buggy #188

Open woodpeck opened 6 years ago

woodpeck commented 6 years ago

When you have some configuration options inside a <VirtualHost>...</VirtualHost> block in Apache, and some others outside (e.g. in a Debian-type "conf_enabled/tileserver.conf" file), then things break and mod_tile reverts to default settings for some things. This is likely due to an issue with create_tile_config and merge_tile_config which I need to debug further.

amandasaurus commented 3 years ago

Subscribing because I had to debug a problem caused by this. The config was like this, with a /etc/apache2/confs-enabled/tileserver.conf for many mod_tile directives, but inside a <VirtualHost> there was a few AddTileConfig directives.

The tile server worked for the first ~100 tile requests, and then it seemed to look for /var/run/renderd/renderd.sock. Since we don't use renderd, it causes 404s for all tiles. The solution was to put ModTileRenderdSocketName in the <VirtualHost> too.

amandasaurus commented 3 years ago

This bug can be reproduced with this apache config:

ModTileRenderdSocketName /run/tirex/modtile.sock
ModTileTileDir /var/cache/tirex/tiles
AddTileConfig /tiles/test test

<VirtualHost *:80>
        DocumentRoot /var/www/html
        LogLevel tile:debug

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        #AddTileConfig /tiles/test3 test 
</VirtualHost>

Running tirex with just a test config.

Get the tile works fine

sudo systemctl reload apache2 ; sudo rm /var/cache/tirex/tiles/test/0/0/0/0/0/0.meta  ; curl localhost/tiles/test/0/0/0.png

Uncomment the #AddTileConfig and it will break and lose the socket name

amandasaurus commented 3 years ago

in the create_tile_config, mod_tile will fill the the config with the default hard coded values, and then the apache directives will set them. so in the above case, the virtualhost will get a freshly created config, and that will be merged with the serverwide config and the hardcoded renderd socket name will be used

amandasaurus commented 3 years ago

I think if you put any config directives in a VirtualHost section, then any config options that you have set outside that are lost and replaced with the compiled in default values.

SomeoneElseOSM commented 3 years ago

@amandasaurus It'd probably help to know what OS you'd hit the problem on - my recollection (albeit from some time ago) is that Ubuntu is that significantly different from Debian in how Apache conf files are set up by default, which has a knock-on effect of "what includes what from where".

amandasaurus commented 3 years ago

this bug is visible on debian & ubuntu. Sorry for the comment spam, I am writing things down here because previously we have forgotten what the problem was.