<div dir="ltr">Hi Geoff,<div><br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div><span style="font-size:12.8000001907349px">I don't know how it works with mediawiki, but let's talk about regexen</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">again. %^)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"><br>> req.http.host ~ "^wiki\.example\.com$"<br><br></span><span style="font-size:12.8000001907349px">If you're going for an exact string match -- '^' followed by a fixed</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">string followed by '$' -- you might as well just compare for string</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">equality:</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> req.http.host == "</span><a href="http://wiki.example.com/" rel="noreferrer" style="font-size:12.8000001907349px" target="_blank">wiki.example.com</a><span style="font-size:12.8000001907349px">"</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">That might be a little faster, and it makes the intention of your code</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">much clearer.</span></div></blockquote><div><br></div><div>Thanks! That makes sense, and I've done that in my next attempt, which I'll show soon.<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">req.url ~<br>
> "^/index.php?title=Special:UserLogin&returnto=Main+Page&returntoquery=action%3Dsubmitlogin%26type%3Dlogin$"<br>
<br>
Same<br>
><br>
thing here, with the additional problem that '.', '?' and '+' are<br>
regex metacharacters. "index.php?" will match "<a href="http://index.ph" rel="noreferrer" target="_blank">index.ph</a>" possibly<br>
followed by a "p", but it won't match the question mark (it also<br>
matches anything where the dot is). "Main+" will match "Mai" followed<br>
one or more "n"s, but it won't match the plus sign.<br>
<br>
So your idea may or may not work with mediawiki, but at any rate the<br>
regex matches were failing.<br>
<br>
If you're sure you're looking for those exact strings, just use the<br>
'==' comparison.<br>
<br>
Are you certain that the URLs of interest will always be written<br>
exactly those two ways? No one will ever use '/' instead of<br>
'/index.php', and the key-value pairs in the query string will always<br>
be in exactly that order?<br>
<br>
If not, you'd be better off using regexen after all, something like this:<br>
<br>
req.url ~ "^/(index\.php)?" && req.url ~ "foo=bar"<br>
&& req.url ~ "baz=quux"<br>
<br>
Meaning: the path must be '/' possibly followed by 'index.php', and<br>
the key-value pairs must all appear (in any order).<br>
<br>
Again, this is just to ensure that you're identifying the URLs you're<br>
looking for, I can't say if mediawiki will then do as you expect.<br></blockquote><div><br></div><div>Ok so for my next attempt, I attempted to clean up the regex a little bit. Hopefully this makes a little more sense:<br><br> if ( req.http.host == "<a href="http://wiki.jokefire.com">wiki.jokefire.com</a>" && req.url ~ "^/(index\.php)?\?title=Special:UserLogin(.*)" ) {<br> return (pass) ;<br> }<br><br> <br></div>
So what I'm doing here is an exact match for the host name and I'm using a regex for the URL. The URL regex means that the string must begin with either a slash or with index.php and after that match "\?title=Special:UserLogin" exactly and then allow any combination of characters after that. I do that because I think that mediawiki varies this URL with some cookie info appended at the end. This theory makes sense to me because I did make some progress with this approach. On the next attempt, instead of having the page simply refresh when I try to log in, I am now getting a new error from mediawiki:<br><br>Login error<br>JF Wiki uses cookies to log in users. You have cookies disabled. Please enable them and try again.<br><br></div><div>So I think I need to find a way to preserve the cookie that's being used to identify the user at the end of the URL, which I'm pretty sure will be a random string. Can you help me find a way to do this?<br><br></div><div>Thanks,<br></div><div>Tim<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 17, 2015 at 2:24 AM, Geoff Simmons <span dir="ltr"><<a href="mailto:geoff@uplex.de" target="_blank">geoff@uplex.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA256<br>
<span><br>
On 8/17/15 5:29 AM, Tim Dunphy wrote:<br>
><br>
> I've setup my mediawiki behind varnish. Since doing that I am<br>
> unable to either create new users or log into the wiki itself.<br>
<br>
</span>I don't know how it works with mediawiki, but let's talk about regexen<br>
again. %^)<br>
<span><br>
> req.http.host ~ "^wiki\.example\.com$"<br>
<br>
</span>If you're going for an exact string match -- '^' followed by a fixed<br>
string followed by '$' -- you might as well just compare for string<br>
equality:<br>
<br>
req.http.host == "<a href="http://wiki.example.com" rel="noreferrer" target="_blank">wiki.example.com</a>"<br>
<br>
That might be a little faster, and it makes the intention of your code<br>
much clearer.<br>
<br>
> req.url ~<br>
> "^/index.php?title=Special:UserLogin&returnto=Main+Page&type=signup"<br>
<br>
><br>
><br>
req.url ~<br>
> "^/index.php?title=Special:UserLogin&returnto=Main+Page&returntoquery=action%3Dsubmitlogin%26type%3Dlogin$"<br>
<br>
Same<br>
><br>
thing here, with the additional problem that '.', '?' and '+' are<br>
regex metacharacters. "index.php?" will match "<a href="http://index.ph" rel="noreferrer" target="_blank">index.ph</a>" possibly<br>
followed by a "p", but it won't match the question mark (it also<br>
matches anything where the dot is). "Main+" will match "Mai" followed<br>
one or more "n"s, but it won't match the plus sign.<br>
<br>
So your idea may or may not work with mediawiki, but at any rate the<br>
regex matches were failing.<br>
<br>
If you're sure you're looking for those exact strings, just use the<br>
'==' comparison.<br>
<br>
Are you certain that the URLs of interest will always be written<br>
exactly those two ways? No one will ever use '/' instead of<br>
'/index.php', and the key-value pairs in the query string will always<br>
be in exactly that order?<br>
<br>
If not, you'd be better off using regexen after all, something like this:<br>
<br>
req.url ~ "^/(index\.php)?" && req.url ~ "foo=bar"<br>
&& req.url ~ "baz=quux"<br>
<br>
Meaning: the path must be '/' possibly followed by 'index.php', and<br>
the key-value pairs must all appear (in any order).<br>
<br>
Again, this is just to ensure that you're identifying the URLs you're<br>
looking for, I can't say if mediawiki will then do as you expect.<br>
<br>
<br>
HTH,<br>
Geoff<br>
- --<br>
UPLEX Systemoptimierung<br>
Scheffelstraße 32<br>
22301 Hamburg<br>
<a href="http://uplex.de/" rel="noreferrer" target="_blank">http://uplex.de/</a><br>
Mob: <a href="tel:%2B49-176-63690917" value="+4917663690917" target="_blank">+49-176-63690917</a><br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)<br>
<br>
iQIcBAEBCAAGBQJV0X4rAAoJEOUwvh9pJNURKLsP/1qI5suvBWXW+BwwXtXmINQY<br>
vPU78Z8JfkdDeXSxmc3lDaazO0L/KE2IwsNnkP5Vl/kJ6EbI3sU8Eq7eXZ73v563<br>
W2d/poA6tlFKHuJovP/opGLhKu1Ls4qUGc74njywNTxiS+pqSvQKPx3OndoYEfyi<br>
/MiPkaPAbSfa7YVKMQ6dHlaEKXP6VJQ3JOJwWKQl4ehl9V1EP1Ddcd2ABHAGf2s+<br>
2yaEINvDVRVek/QBkzgzZbN//KXjtpQdtELjSriNAAAUV+Oi1ULP9ROL0QE+IVYO<br>
Gqe9q0AxquOxn7D6DFgUyZmZWgEjDPy3V8JvNMI+drwTewhEk1g9A1yOI9v+5RJb<br>
MDO6t7RWR+m9VTO0dsXiCXyRYZzUrn2nnwYysYvUy5PdfaHF+4xQBN9hniAu49AQ<br>
nHqfwaY6C1eDATLkqlDvrsFcwySr5sF2Ax6H3BiKV5seuQ5n+dpy6RdKBi+YDIBy<br>
GBy4YEYwDkPyLmXPyNt3izY3rxmmob/aaoKBRpBJOMuuVDyKiqRNaUmIVkvMHAUb<br>
S0UFQ+dMdsuak6z/ei/32p/vNvZvEuQG5s97FLDui9BpVa1Q8W5Lkamyy96I2WSQ<br>
Y0iPQludnzm1TQ9FLYp0tJPTW4UTbWi9tyUn35d8vKsaNkqUTTAk/UH1FQvaQ2n6<br>
tm2gtaXXQc6n1yD6xY29<br>
=89fY<br>
-----END PGP SIGNATURE-----<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>GPG me!!<br><br>gpg --keyserver <a href="http://pool.sks-keyservers.net" target="_blank">pool.sks-keyservers.net</a> --recv-keys F186197B<br><br></div>
</div></div>