【发布时间】:2018-09-10 07:39:21
【问题描述】:
所以,我一直在配置 DNS:name.centralindia.cloudapp.azure.com,它可以运行 Ubuntu 16.05 LTS VM。我们希望网站在 SSL 证书下得到保护,所以我已经安装了“Nginx 服务器”来完成后端工作。我已将 Nginx 服务器配置为指向我们的自定义 DNS,但我一直面临 nginx 配置的问题。当我们进入 https/http 时,出现“Bad Gateway”错误或“Nginx 欢迎页面”或 Not found 404 错误。
不知何故,在 nginx 服务器的帮助下,我们需要使用已经安装在 ssl_certificate /etc/ssl/certs/azurevm.crt; ssl_certificate_key /etc/ssl/private/azurevm.key; (这些是在 Ubuntu 中生成的自签名密钥,但我们需要使用生成并存储在 Azure 密钥库中的密钥证书,名称为“xxcert”,我在 ubuntu 中找不到(var/lib/waagent))
我还按照此链接保护 Azure 中的 Web 服务器:https://docs.microsoft.com/en-us/azure/virtual-machines/windows/tutorial-secure-web-server,但此安装是在首次启动 VM 时完成的,但在我的情况下,我已经安装了 Vm。
这是我在 /etc/nginx/sites-available/default 下的默认配置(未对站点启用/默认进行任何更改):
默认服务器配置
server {
listen 80 default_server;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
}
server {
# SSL configuration
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name name.centralindia.cloudapp.azure.com;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
# ssl_certificate /etc/nginx/ssl/vmcert.pem;
# ssl_certificate_key /etc/nginx/ssl/vmcert.key;
ssl_certificate /etc/ssl/certs/azurevm.crt;
ssl_certificate_key /etc/ssl/private/azurevm.key;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://localhost:8000;
proxy_read_timeout 90;
proxy_redirect http://localhost:8000
http://name.centralindia.cloudapp.azure.com;} )
【问题讨论】:
-
您的真正问题是什么?如何从 Key Vault 导出 pub/priv 密钥对?
-
有没有办法将密钥和证书导出到托管虚拟机,并在 nginx/sites-avaibled/default.xml 中使用。因为我尝试使用 az vm update 更新密钥,但密钥在 var/lib/waagent 中不可用。