【发布时间】:2021-01-09 14:36:40
【问题描述】:
我正在使用 Azure Kubernetes 来使用 Docker 容器托管 Angular Web 应用程序。 我已经使用 OpenSSL 命令创建了 SSL 证书。现在,我需要为我的 Web 应用程序配置 HTTPS 和 SSL 证书。
请帮助我如何设置这些?
这是我的 Docker 文件
FROM nginx:latest as nginx
RUN rm -rf /usr/share/nginx/html/*
COPY /dist/merch-insight/nginx.conf /etc/nginx/conf.d/nginx.conf
COPY /dist/merch-insight /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
这是我的 nginx.conf 文件
server {
server_name my-app;
charset utf-8;
sendfile on;
root /usr/share/nginx/html;
#Caches static assets
location ~ ^/(assets|bower_components|scripts|styles|views) {
expires 31d;
add_header Cache-Control public;
}
#Caches Bundles created by angular cli
location ~* \.(?:bundle.js|bundle.css)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
##
# Main file index.html sending not found locations to the main
##
location / {
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
这是我的 yaml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: apweb
version: v1
name: apweb
namespace: default
spec:
selector:
matchLabels:
run: apweb
replicas: 2
template:
metadata:
labels:
run: apweb
spec:
containers:
- name: apweb
image: mycontainerregistry.azurecr.io/apweb:dev
imagePullPolicy: Always
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
labels:
app: apweb
version: v1
name: apweb-service
namespace: default
spec:
type: LoadBalancer
ports:
- port: 80
protocol: TCP
targetPort: 80
name: http-web
selector:
run: apweb
【问题讨论】:
标签: docker ssl kubernetes https azure-aks