我想将我的 Web 应用程序容器化。目前,我正在使用Apache提供几个PHP应用程序。
\n每个应用程序都应由自己的容器提供。\nNginx 应可通过端口 80/443访问。根据子路由,它应该代理到容器之一。
\n例如:
\nwww.url.de/hello1 --> hello1:80\nwww.url.de/hello2 --> hello2:80\nRun Code Online (Sandbox Code Playgroud)\ndocker-compose.yml:
\nversion: '3'\nservices:\n nginx:\n image: nginx:latest\n container_name: reverse_proxy\n volumes:\n - ./nginx.conf:/etc/nginx/nginx.conf\n ports:\n - "80:80"\n - "443:443"\n networks:\n - app-network\n depends_on:\n - hello1\n - hello2\n\n hello1:\n build: ./test1\n image: hello1\n container_name: hello1\n expose:\n - "80"\n networks:\n - app-network\n hello2:\n build: ./test2\n image: hello2\n container_name: hello2\n expose:\n - "80"\n networks:\n - app-network\n\nnetworks:\n app-network:\nRun Code Online (Sandbox Code Playgroud)\nnginx.conf:
\nevents {\n\n}\n\nhttp {\n …Run Code Online (Sandbox Code Playgroud) 我有几个在 Kubernetes 上运行的 Web 应用程序。为了匹配我使用 NGINX 入口的请求。目前,所有应用程序都分别验证来自我们的身份提供者的令牌(我在开发中使用 Keycloak 并计划用于生产的 Azure Active Directory)。
是否可以在 Ingress 级别进行验证?
例如,用户尝试进入页面。Ingress 检查有效令牌并在必要时重定向到 IP。如果用户成功登录,入口控制器将令牌提供给应用程序。
我需要如何配置 Angular 7 应用程序正在运行的入口?
\napiVersion: extensions/v1beta1\nkind: Ingress\nmetadata:\n name: myingress\n annotations:\n nginx.ingress.kubernetes.io/rewrite-target: /\n nginx.ingress.kubernetes.io/use-regex: "true"\nspec:\n rules:\n - http:\n paths:\n - path:\n backend:\n serviceName: angular-service\n servicePort: 80\n - path: /test\n backend:\n serviceName: angular-service\n servicePort: 80\nRun Code Online (Sandbox Code Playgroud)\nAngular 由 nginx 镜像托管:
\nFROM nginx:alpine\nCOPY . /usr/share/nginx/html\nRun Code Online (Sandbox Code Playgroud)\n在 Kubernetes 上:
\nFROM nginx:alpine\nCOPY . /usr/share/nginx/html\nRun Code Online (Sandbox Code Playgroud)\n在路上/一切正常。但在上面/test不起作用。\n控制台输出:
> Uncaught SyntaxError: Unexpected token < runtime.js:1 \n\n> Uncaught SyntaxError: Unexpected token < polyfills.js:1\n\n> Uncaught SyntaxError: Unexpected token < main.js:1\n …Run Code Online (Sandbox Code Playgroud) 我的 AKS 可以通过 nginx-ingress 访问。一切都适用于 https,但由于我使用 https,nginx 无法匹配任何路由并使用默认后端。
我使用的是 Kubernetes 版本 1.15。我将域名更改为 example.com,将 IP 更改为 51.000.000.128。SSL 证书由外部提供商 (digicert) 签名。
入口控制器
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
Run Code Online (Sandbox Code Playgroud)
入口服务
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud-generic.yaml
Run Code Online (Sandbox Code Playgroud)
入口.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-ingress
namespace: ingress-nginx
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - kp-user'
spec:
tls:
- hosts:
- example.com
secretName: ssl-secret
rules:
- host: example.com
- http:
paths:
- path: /app1(/|$)(.*)
backend:
serviceName: app1-service
servicePort: 80
- path: …Run Code Online (Sandbox Code Playgroud) 我试图从砖块中提取一些信息。不幸的是,Bricks API是基于SOAP标准构建的,并且不支持JSON。如果我使用HTTP获取数据,那么一切都可以正常工作:
<ArrayOfSets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="https://brickset.com/api/">
<sets>
<setID>494</setID>
<number>1665</number>
<numberVariant>1</numberVariant>
<name>Dual FX Racers</name>
Run Code Online (Sandbox Code Playgroud)
因此身份验证有效。我试图通过Python(3.6)Urllib来获得响应:
import urllib.request
html = urllib.request.urlopen('https://brickset.com/api/v2.asmx/...')
print(html)
Run Code Online (Sandbox Code Playgroud)
结果看起来像这样:
我已经尝试通过beautifulsoup4从此url获取数据,但是没有用。我每次都有一个空数组。
编辑:新代码取决于1N5818答案
from zeep import Client
wsdl_url = "https://brickset.com/api/?wsdl"
soap_client = Client(wsdl_url)
result = soap_client.getSet("xxx","xxx","494")
Run Code Online (Sandbox Code Playgroud)
WSDL DOKU:
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="https://brickset.com/api/">
<s:element name="getSet">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="apiKey" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="userHash" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="SetID" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
Run Code Online (Sandbox Code Playgroud)
好吧,我误会了。但是,如果我执行此代码,则会出现以下错误:
AttributeError:“客户端”对象没有属性“ getSet”
我怎么了