首页 > 解决方案 > Azure VM - 使用 Nginx 进行 DNS 配置

问题描述

所以,我一直在配置 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 密钥指向我们的 DNS;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 ,但是这个安装是在第一次启动虚拟机,但在我的情况下,我已经安装了虚拟机。

这是我在 /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;} )

标签: azuresslnginx

解决方案


我认为您想将您的 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/

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


推荐阅读