azure - 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;} )
解决方案
我认为您想将您的 SSL 证书绑定到服务器。为此,您必须转到 APP 服务 SSL 设置。查看 - https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-SSL
存在版本差异,但会提供一些帮助。
推荐阅读
- android - 如何将 com.google.firebase.Timestamp 转换为 SQLite 可存储数据?
- html - 框不断下降到下一行 float: right
- vba - 如何使用 VBA 将 powerpoint 部分复制到新的演示文稿中
- reactjs - 在接口和类中多次指定相同声明的概念是什么?
- php - 如何更新 php mysql 中的特殊子行
- java - 我怎么能关闭一个netty客户端?
- python - 熊猫:点和 [] 之间的区别
- php - 我需要在 url 中添加一个变量
- sql - 如何创建查询以连接三个表并在 SQL 中进行计算?
- wordpress - woocommerce类别页面中的产品自定义订单