【问题标题】:Azure VM - DNS config with NginxAzure VM - 使用 Nginx 进行 DNS 配置
【发布时间】: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 中不可用。

标签: azure ssl nginx


【解决方案1】:

我认为您想将您的 SSL 证书绑定到服务器。 为此,您必须转到 APP 服务 SSL 设置。 签出-https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-SSL

您也可以关注以下帖子: https://blogs.msdn.microsoft.com/appserviceteam/2016/05/24/deploying-azure-web-app-certificate-through-key-vault/

存在版本差异,但会提供一些帮助。

【讨论】:

  • 我在 Azure VM 中托管 Ubuntu,那么这也是将 SSL 证书绑定到托管 VM 的方法吗?我已经安装了 nginx 并尝试使用 Lets Encrypt 中的密钥,现在我可以看到带有安全绿色指示灯的挂锁,但是当我登录到 name.centralindia.cloudapp.azure.com 时,我看到了 Bad Gateway Not found 错误。所以我相信 dns 没有从服务器获得所需的响应。我该如何解决这个问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-27
  • 1970-01-01
  • 1970-01-01
  • 2021-10-14
  • 2019-11-05
相关资源
最近更新 更多