Page MenuHomePhabricator

ncredir redirects for status.wiki* --> status.wikimedia.org
Open, Stalled, LowPublic

Description

Was hoping to use ncredir to implement redirects towards status.wikimedia.org for many sources of the form like:

status.wikibooks.org
status.wikivoyage.com
status.wikipedia.net
etc etc

However if I'm understanding nc_redirects.dat correctly, it looks like that wildcards are supported only as prefixes, not suffixes? What's the best way to do this?

Event Timeline

BCornwall moved this task from Backlog to Ready for work on the Traffic board.

Looks like interpret_wildcard() in compile_redirects.rb does not support suffixed wildcards:

def interpret_wildcard(wildcard)
  case wildcard
  when /^\*\.([^*]*)/
    [{
      :domain_regex => '^(.+)\.' << Regexp.quote(Regexp.last_match[1]) << '$',
      :alias        => wildcard,
    }]
  when /^\*([^*]*)/
    [{
      :domain_regex => '=' + Regexp.last_match[1],
      :alias        => Regexp.last_match[1],
    }, {
      :domain_regex => '^(.+)\.' << Regexp.quote(Regexp.last_match[1]) << '$',
      :alias        => '*.' << Regexp.last_match[1],
    }]
  when /\*/
    error("invalid use of asterisk in domain pattern")
  else
    [{
      :domain_regex => '=' + wildcard,
      :alias        => wildcard,
    }]
  end
end

I imagine this could be extended but compile_redirects.rb is really gnarly and I'd be afraid of unintentional breakage. ._.

Looking into it further, it seems this is a very possible change! nginx mappings/site names support wildcards.

Pulling back a bit, does anything other than ncredir even use compile_redirects.rb? If not, why not just... maintain the maps file directly? This would be a non-issue if that were the case.

Looking into it further, it seems this is a very possible change! nginx mappings/site names support wildcards.

Pulling back a bit, does anything other than ncredir even use compile_redirects.rb? If not, why not just... maintain the maps file directly? This would be a non-issue if that were the case.

There are two main users of compile_redirects.rb:

  • ncredir (nginx) for non-canonical domains redirects modules/ncredir/files/nc_redirects.dat
  • mediawiki (Apache) for canonical domain redirects. modules/mediawiki/files/apache/sites/redirects/redirects.dat

A list of canonical domains can be found here: https://wikitech.wikimedia.org/wiki/HTTPS#Foundation_canonical_domain_names.

From my understanding of the task description, it impacts both non-canonical domain redirects and canonical domain redirects

Thank you for the clarification, @Vgutierrez. Do you have a suggestion on how to reconcile this? My instinct is to remove the abstraction entirely and maintain two separate mappings if they're going to diverge anyway.

BCornwall changed the task status from Open to Stalled.Aug 11 2023, 8:18 PM