我试图让 NGINX 的解析器自动更新 DNS 解析缓存,所以我正在过渡到使用变量作为proxy_pass值来实现这一点。但是,当我确实使用变量时,它会使所有请求都转到请求的根端点并切断 url 的任何其他路径。这是我的配置:
resolver 10.0.0.2 valid=10s;
server {
listen 80;
server_name localhost;
location /api/test-service/ {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# If these 2 lines are uncommented, 'http://example.com/api/test-service/test' goes to 'http://example.com/api/test-service/'
set $pass_url http://test-microservice.example.com:80/;
proxy_pass $pass_url;
# If this line is uncommented, things work as expected. 'http://example.com/api/test-service/test' goes to 'http://example.com/api/test-service/test'
# proxy_pass http://test-microservice.example.com:80/;
}
Run Code Online (Sandbox Code Playgroud)
这对我来说没有任何意义,因为硬编码的 URL 和变量的值是相同的。有什么我想念的吗?
编辑:啊,所以我发现了这个问题。但我不完全确定如何处理它。由于这是一个反向代理,我需要在将 URI 传递给代理之前从 URI 中proxy_pass删除/api/test-service/它。所以..
这个:
http://example.com/api/test-service/test
Run Code Online (Sandbox Code Playgroud)
应该代理这个:
http://test-microservice.example.com:80/test
Run Code Online (Sandbox Code Playgroud)
而是代理这个: …
在 nginx 容器的 proxy_pass 配置中使用变量重写和代理内部 Openshift 服务时,由于需要解析器,NGINX 无法解析服务的 DNS。例如:
location /api/ {
set $pass_url http://service.namespace.svc:8080$request_uri;
proxy_pass $pass_url;
}
Run Code Online (Sandbox Code Playgroud)
使用标准 Kubernetes 时,我可以kube-dns.kube-system.svc.cluster.local用作解析器:
resolver kube-dns.kube-system.svc.cluster.local;
Run Code Online (Sandbox Code Playgroud)
但是 Openshift 不提供这个。我尝试使用容器中的 IP /etc/resolv.conf,它只是运行 DNS 服务器的集群中的节点之一,但它仍然无法解析。
最奇怪的部分是nslookup service.namespace.svc从容器终端内部使用名称服务器/etc/resolv.conf,它工作正常。
我可以使用 Openshift 中的 Kubernetes DNS 主机名,或者其他解决方案来解决这个问题?
在我正在构建的索引中,我对运行查询感兴趣,然后(使用facets)返回该查询的带状疱疹.这是我在文本中使用的分析器:
{
"settings": {
"analysis": {
"analyzer": {
"shingleAnalyzer": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"custom_stop",
"custom_shingle",
"custom_stemmer"
]
}
},
"filter": {
"custom_stemmer" : {
"type": "stemmer",
"name": "english"
},
"custom_stop": {
"type": "stop",
"stopwords": "_english_"
},
"custom_shingle": {
"type": "shingle",
"min_shingle_size": "2",
"max_shingle_size": "3"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
主要问题是,使用Lucene 4.4,停止过滤器不再支持enable_position_increments参数来消除包含停用词的带状疱疹.相反,我会得到像...的结果
"红色和黄色"
"terms": [
{
"term": "red",
"count": 43
},
{
"term": "red _",
"count": 43
},
{
"term": "red _ yellow",
"count": 43
}, …Run Code Online (Sandbox Code Playgroud) 当使用以下JSON并且"phones"或"emailAddresses"为空时,我收到NullPointerException.
JSON:
{
"item": {
"messages": {
"user.phone.missing": {
"type": "warning",
"key": "user.phone.missing",
"message": "User profile does not have a phone number",
"code": null
},
"user.email.missing": {
"type": "warning",
"key": "user.email.missing",
"message": "User profile does not have an email address",
"code": null
},
"user.es.sync.failed": {
"type": "error",
"key": "user.es.sync.failed",
"message": "Unable to sync user",
"code": null
}
},
"user": {
"firstName": "Test",
"middleInitial": null,
"lastName": "User",
"createdDt": "2016-04-20 19:50:03+0000",
"updatedDt": null,
"lastVerifiedDt": null,
"status": "DEACTIVATED",
"tokens": [
{
"tokenHash": "test …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用NSS数据库中的证书存储区进行cURL,但是在运行cURL命令时,它说找不到证书。这是我的数据库中的证书列表:
[root@localhost scripts]# certutil -L -d /nss
Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI
Test User u,u,u
Test Root CA ,,
Test SUBCA2 ,,
Run Code Online (Sandbox Code Playgroud)
您可以在其中看到“测试用户”证书。我还确认SSL_DIR设置为数据库目录:
[root@localhost scripts]# echo $SSL_DIR
/nss
Run Code Online (Sandbox Code Playgroud)
但是,当我运行cURL命令时:
[root@localhost etc]# curl -vk --cert "Test User" https://localhost:7446
* About to connect() to localhost port 7446 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 7446 (#0)
* Initializing NSS with certpath: sql:/nss
* warning: ignoring value of ssl.verifyhost
* skipping SSL peer certificate verification
* NSS: client certificate …Run Code Online (Sandbox Code Playgroud) 我的目标是构建一个索引,对于每个文档,将通过单词ngrams(uni,bi和tri)将其分解,然后捕获所有这些单词ngrams上的术语向量分析.Elasticsearch可以吗?
例如,对于包含"红色汽车驱动器"的文档字段.我将能够获得这些信息:
red - 1 instance
car - 1 instance
drives - 1 instance
red car - 1 instance
car drives - 1 instance
red car drives - 1 instance
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我的用例需要传递 SSL,因此很遗憾我们无法在 Openshift 中本地使用基于路径的路由。我们的下一个最佳解决方案是设置一个内部 NGINX 代理,以将流量从路径路由到另一个 Web UI 的 Openshift 路由。这样做时出现错误。
这是我的简化 NGINX 配置:
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /etc/nginx/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
upstream app1-ui-1-0 {
server app1-1-0.192.168.99.100.nip.io:443;
}
server {
listen 8443 ssl default_server;
location /apps/app1/ {
proxy_pass https://app1-ui-1-0/;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的app1路由配置如下:
apiVersion: v1
kind: Route
metadata:
name: app1-1-0
spec:
host: app1-1-0.192.168.99.100.nip.io
to:
kind: Service
name: app1-1-0
tls:
insecureEdgeTerminationPolicy: Redirect
termination: passthrough
Run Code Online (Sandbox Code Playgroud)
当我点击 时https://app1-1-0.192.168.99.100.nip.io,该应用程序运行良好。
当我点击 NGINX 代理路由 url ( https://proxier-1-0.192.168.99.100.nip.io …
nginx ×3
openshift ×2
resolver ×2
certificate ×1
curl ×1
dns ×1
jackson ×1
java ×1
json ×1
lucene ×1
n-gram ×1
nss ×1
objectmapper ×1
proxy ×1
proxypass ×1
routes ×1
stop-words ×1
term-vectors ×1
variables ×1