For the same host name, I want to do mapping like the following
/subdirectory/_different_end_points_.json map to 127.0.0.1:9001
/_different_end_points_.json map to 127.0.0.1:9002
How to do that? per documentation, it's required that the else clause has to match on a condition as well, which drives me nuts (as a beginner on regular expression)
Have you tried something like that:
$HTTP["url"] =~ "^/subdirectory/_different_end_points_.json" {
proxy.server = (
"/" => (("host" => "127.0.0.1", "port" => 9001))
)
}
else $HTTP["url"] =~ "^/_different_end_points_.json" {
proxy.server = (
"/" => (("host" => "127.0.0.1", "port" => 9002))
)
}
That way, you match each url that starts with /subdirectory/_different_end_points_.jso or (in the else) /_different_end_points_.json.
But be sure that your url realy start with the regex! I mean: h*tp://sample.com/subdirectory/_different_end_points_.json and h*tp://sample.com/_different_end_points_.json
Related
I've had a look on the other questions surrounding this problem but it doesn't seem to help.
I'm having to change an input of "i phone" or "i Phone" to query "iPhone" in Elasticsearch.
As you can see, I have tried most everything I can think of, including simply "phone => iPhone" and leaving the "i" in there to hang around and possibly add it to the stopwords.
I've tried using "simple", "keyword", "standard" and "whitespace" for my custom analyzer.
Can anyone spot where I've gone wrong, this is the last problem before I can finish my project so it'd be appreciated. Thanks
P.S. Bonus points if you include how I can do auto suggest on inputs, thanks
Below is my code
public static CreateIndexDescriptor GetMasterProductDescriptor(string indexName = "shopmaster")
{
var indexDescriptor = new CreateIndexDescriptor(indexName)
.Settings(s => s
.Analysis(a => a
.TokenFilters(t => t
.Stop("my_stop", st => st
.StopWords("_english_", "new", "cheap")
.RemoveTrailing()
)
.Synonym("my_synonym", st => st
.Synonyms(
"phone => iPhone"
//"i phone => iPhone",
//"i Phone => iPhone"
)
)
.Snowball("my_snowball", st => st
.Language(SnowballLanguage.English)
)
)
.Analyzers(an => an
.Custom("my_analyzer", ca => ca
.Tokenizer("simple")
.Filters(
"lowercase",
"my_stop",
"my_snowball",
"my_synonym"
)
)
)
)
)
.Mappings(
ms => ms.Map<MasterProduct>(
m => m.AutoMap()
.Properties(
ps => ps
.Nested<MasterProductAttributes>(p => p.Name(n => n.MasterAttributes))
.Nested<MasterProductAttributes>(p => p.Name(n => n.ProductAttributes))
.Nested<MasterProductAttributeType>(p => p.Name(n => n.MasterAttributeTypes))
.Nested<Feature>(p => p.Name(n => n.Features))
.Nested<RelatedProduct>(p => p.Name(n => n.RelatedProducts))
.Nested<MasterProductItem>(
p => p.Name(
n => n.Products
)
.Properties(prop => prop.Boolean(
b => b.Name(n => n.InStock)
))
)
.Boolean(b => b.Name(n => n.InStock))
.Number(t => t.Name(n => n.UnitsSold).Type(NumberType.Integer))
.Text(
tx => tx.Name(e => e.ManufacturerName)
.Fields(fs => fs.Keyword(ss => ss.Name("manufacturer"))
.TokenCount(t => t.Name("MasterProductId")
.Analyzer("my_analyzer")
)
)
.Fielddata())
//.Completion(cm=>cm.Analyzer("my_analyser")
)
)
);
return indexDescriptor;
}
The order of your filters matters!
You are applying lowercase, then a stemmer (snowball) then synonyms. You synonyms contain capital letters, but by the time they are applied, lowercasing has already occurred. It's a good idea to apply lowercasing first, to make sure case doesn't affect matching of the synonyms, but your replacements, in the that case, shouldn't have caps.
Stemmers should not be applied before synonyms (unless you know what you are doing, and are comparing post-stemming terms). Snowball, I believe, will transform 'iphone' to 'iphon', so this is another area where you are running into trouble.
"lowercase",
"my_synonym",
"my_stop",
"my_snowball",
(And don't forget to remove the caps from your synonyms)
I am attempting to set up a proxy + rewrite with lighttpd.
I am trying to reverse proxy to two separate servers. The first is meant to be at root (192.168.1.198:7000) and the second is meant to be accessed through the /ram/ directory (192.168.1.197:8000). I am using version 1.4.38-1 of lighttpd and do not have the option of upgrading.
The below is the relevant portion of my lighttpd.config, I am hoping someone can point me to my error!
$SERVER["socket"] == ":82" {
url.rewrite-once = ( "^/ram/(.*)$" => "/$1" )
proxy.server = ( "" => (
"" =>
( "host" => "192.168.1.197",
"port" => 8000
)
)
)
}
else $HTTP["host"] == "subdomain.example.com" {
proxy.balance = "hash"
proxy.server = ( "" => ( ( "host" => "192.168.1.198", "port" => 7000 ) ) )
$HTTP["url"] =~ "(^/ram/)" {
proxy.server = ( "" => (
"" =>
( "host" => "127.0.0.1",
"port" => 81
)
)
)
}
}
FYI, I see three backend proxy servers configured, not two.
Also, all requests from a client to port :82 on your server will be handled by the first conditional block. The 'else $HTTP["host"] == "subdomain.example.com"' will never be seen by clients connecting to port :82 on your lighttpd server.
If you want all requests with Host: subdomain.example.com to follow the instructions in that conditional block, then make that section a standalone 'if' rather than an 'else' tacked on to the first condition ($SERVER["socket"] == ":82")
I have following lighttpd redirect rules and would need to convert them to nginx:
url.rewrite-once = (
"^/misc(.*)" => "/misc$1",
"^/show_fileupload.php(.*)" => "/show_fileupload.php$1",
"^/flash(.*)" => "/flash$1",
"^/images(.*)" => "/images$1",
"^/css(.*)" => "/css$1",
"^/js(.*)" => "/js$1",
"^/filestore(.*)" => "/filestore$1",
"/(([a-f0-9]{32})/)?(app/(.+?)/)(lang/(\w{2}-\w{2}|\w{2}|)/)?/*([^\?]*)(?:\?(.*))?" => "/$4.php?rs_module_uri=$7&rs_session=$2&rs_app=$4&rs_lang=$6&$8",
"/(([a-f0-9]{32})/)?(app//)?(lang/(\w{2}-\w{2}|\w{2}|)/)?/*([^\?]*)(?:\?(.*))?" => "/main.php?rs_module_uri=$6&rs_session=$2&&rs_lang=$5&$7",
)
How to convert especially the last two lines?
I finally got it to work, it's even not that different:
rewrite "/(([a-f0-9]{32})/)?(app/(.+?)/)(lang/(\w{2}-\w{2}|\w{2}|)/)?/*([^\?]*)(?:\?(.*))?" /$4.php?rs_module_uri=$7&rs_session=$2&rs_app=$4&rs_lang=$6&$8 last;
rewrite "/(([a-f0-9]{32})/)?(app//)?(lang/(\w{2}-\w{2}|\w{2}|)/)?/*([^\?]*)(?:\?(.*))?" /main.php?rs_module_uri=$6&rs_session=$2&&rs_lang=$5&$7 last;
Current relavent config from lighttpd.conf:
url.rewrite = (
"^/(.*)\.(.+)$" => "$0",
"^/(.+)/?$" => "/index.php/$1",
)
and
alias.url += (
"/xcache/" => "/usr/share/xcache/"
)
I cant get them to work together. From what I understand, the rewrite hijacks the "/xcache/" url thus not triggering the alias.url.
They both work perfectly fine on their own, but cannot get them to work together. Is there a way to exclude certain strings from the url.rewrite expression?
Solved it:
url.rewrite = (
"^/(xcache)/(.*)" => "$0",
"^/(.*)\.(.+)$" => "$0",
"^/(.+)/?$" => "/index.php/$1",
)
alias.url += (
"/xcache/" => "/usr/share/xcache/"
)
I just got some problems serving static files via Lighttpd.
Here's what I would want to do:
www.example.ch is my domain.
If a call comes to www.example.ch/static/.....css
then I want to reroute it and actually serve the file from static.example.ch/files/....css (see my url.rewrite-once rule).
Somehow this just doesn't work. Am I missing something completely?
$HTTP["host"] =~ "(^|\.)example\.ch$" {
fastcgi.server = (
"/django.fcgi" => (
"main" => (
"socket" => env.HOME + "/webqs/webqs.sock",
"check-local" => "disable",
)
),
)
alias.url = (
"/media" => env.HOME + "/webqs/media",
)
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/static.*)$" => "http://static.example.ch/files/$1",
"^(/.*)$" => "/django.fcgi$1",
)
}
Given the regular expression "^(/static.*)$" it looks like $1 is going to contain /static/...css. Is there a static/ directory under your files/ directory? If not, try changing the regular expression to something like:
"^/static/(.*)$"
This should match everything after /static/ but won't also include the string /static/.