Page MenuHomePhabricator

Custom mod_alias config not allowed for tools due to default lighttpd configuration
Closed, ResolvedPublic

Description

aliases config for a tool doesn't seem to be working as expected

My config lighttpd.conf
alias.url += ("/api" => "/data/project/interaction-timeline/tool/server/src/public")

on the logs

2018-01-30 18:20:29: (response.c.545) Doc-Root     : /data/project/interaction-timeline/public_html
2018-01-30 18:20:29: (response.c.546) Basedir      : /data/project/interaction-timeline/public_html/
2018-01-30 18:20:29: (response.c.547) Rel-Path     : /interaction-timeline/api/hello
2018-01-30 18:20:29: (response.c.548) Path         : /data/project/interaction-timeline/public_html//api/hello
2018-01-30 18:20:29: (response.c.565) -- handling physical path
2018-01-30 18:20:29: (response.c.566) Path         : /data/project/interaction-timeline/public_html//api/hello
2018-01-30 18:20:29: (response.c.624) -- file not found
2018-01-30 18:20:29: (response.c.625) Path         : /data/project/interaction-timeline/public_html//api/hello

The same config is applied to a container using phpdocker-registry.tools.wmflabs.org/toollabs-php-web image and it works just fine

Event Timeline

Should the alias also include the toolname? e.g.

alias.url += ("/interaction-timeline/api" => "/data/project/interaction-timeline/tool/server/src/public")

I tried that as the docs were prescribing it in that format but this was happening

2018-01-30 08:01:24: (mod_alias.c.106) url.alias: `/interaction-timeline/' will never match as `/interaction-timeline' matched first
2018-01-30 08:01:24: (server.c.1022) Configuration of plugins failed. Going down.

which makes sense because the default config on toolforge includes this
alias.url = ( "/{toolname}" => "{home}/public_html/" )

This might not be a bug at all and it is me not knowing how to set it up. But it works with the same image in a local container and not on toolforge

I seem to have confused things here. Seeing the full lighttpd.conf it seems clear that it is not possible to add an alias (lighttpd will complain about the same prefix, or set it directly without the toolname prefix). Symbolic links or rewrites will have to be used to achieve this result.

Priority low, all I see that is left is to change docs to reflect actual lighttpd behaviour.

Pardon my ignorance but why do we need alias.url = ( "/{toolname}" => "{home}/public_html/" ) as part of the default config? Shouldn't it just work without it considering that the document root is pointing to the same directory?

Pardon my ignorance but why do we need alias.url = ( "/{toolname}" => "{home}/public_html/" ) as part of the default config? Shouldn't it just work without it considering that the document root is pointing to the same directory?

The document root does point at that directory, but the public URL space is https://tools.wmflabs.org/$TOOLNAME. The lighttpd instance that is running for a given tool sees URLs with the $TOOLNAME prefix and would otherwise not know how to route them. It's gross and someday we will fix it with T125589: Allow each tool to have its own subdomain for browser sandbox/cookie isolation so that the public URL space is something like https://$TOOLNAME.toolforge.org instead.

bd808 renamed this task from mod_alias config for toolforge doesn't seem to be working to Custom mod_alias config not allowed for tools due to default lighttpd configuration.Mar 11 2018, 12:51 AM
bd808 edited projects, added Toolforge; removed cloud-services-team.

lighttpd 1.4.46 (released Oct 2017) allows overridding of configurations using e.g. alias.url := ( ... )

In all versions of lighttpd, you can override (replace!) most global config by creating a condition and defining the directive within that condition, e.g.

$HTTP["scheme"] == "https" {
    alias.url = ( ... )
}

Of course, if wikimedia wants to provide a baseline set of aliases, the user-specific ~/.lighttpd.conf might be included earlier in lighttpd.conf, and then the baseline set of aliases could be included and alias.url += ( ... ) afterwards.

so that the public URL space is something like https://$TOOLNAME.toolforge.org instead.

As this is now done, should this task be closed?

bd808 claimed this task.

Closing following implementation of T125589: Allow each tool to have its own subdomain for browser sandbox/cookie isolation. The prior alias usage in the default lighttpd config was removed by rOSTW4a7d1094dea7: Remove --canonical argument to webservice.