Azure VM - 使用 Nginx 配置 DNS

标签 azure ssl nginx

因此,我一直在配置 DNS:name.centralindia.cloudapp.azure.com,它可以运行 Ubuntu 16.05 LTS VM。我们希望网站在 SSL 证书下得到保护,所以我已经安装了“Nginx 服务器”来完成后端工作。我已将 Nginx 服务器配置为指向我们的自定义 DNS,但我一直面临 nginx 配置问题。当我们进入 https/http 时,出现“Bad Gateway”错误或“Nginx 欢迎页面”或“找不到 404”错误。

不知何故,在 nginx 服务器的帮助下,我们需要使用已经安装在服务器中的 SSL key 指向我们的 DNS ssl_certificate/etc/ssl/certs/azurevm.crt; ssl_certificate_key/etc/ssl/private/azurevm.key; (这些是在 Ubuntu 中生成的自签名 key ,但我们需要使用生成并存储在 Azure keystore 中的 key 证书,名称为“xxcert”,我在 ubuntu (var/lib/waagent) 中找不到)

我还点击了此链接以保护 Azure 中的 Web 服务器:https://learn.microsoft.com/en-us/azure/virtual-machines/windows/tutorial-secure-web-server , 但此安装是在首次启动 VM 时完成的,但在我的情况下,我已经安装了 Vm。

这是我在/etc/nginx/sites-available/default 下的默认配置(未对 site-enabled/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;} )

最佳答案

我想你想将你的 SSL 证书绑定(bind)到服务器。 为此,您必须转到 APP 服务 SSL 设置。 查看- https://learn.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 - 使用 Nginx 配置 DNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52253130/

相关文章:

azure - 应用服务 VNet 与 Azure 存储服务端点集成

node.js - 我可以在 Azure 应用服务上运行 Node/ExpressJS 应用程序还是必须使用 Azure 云服务?

file-upload - session 上传进度是否适用于 nginx 和 php-fpm?

nginx - kubernetes nginx到子域重定向的入口子路径

IoT 中心和诊断设置的 Azure 模板部署不起作用

Azure WebJob 不接受有效的(?)CRON 表达式

php - 如何在 Apache 中访问一个文件夹?

encryption - 安全与认证 : SSL vs SASL

facebook - 带有 woobox 的 iframe facebook 应用程序

django - nginx + Gunicorn 抛出截断的响应正文