python - 如何删除在 AWS ubuntu 服务器中创建的自签名 SSL 证书

标签 python amazon-web-services ubuntu ssl nginx

您好,我已经在 AWS ubuntu 服务器中部署了一个简单的 flask python web,遵循了这些人的电子书(https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vii-error-handling)。但是我发现有问题,当我想通过浏览器访问网络时。 我在chrome浏览器访问该站点时,出现如图所示的安全警告。虽然我可以单击“处理到...”以成功访问该站点。

issue

但我不希望在访问网站时显示警告图像。

我发现这个问题是由AWS ubuntu 服务器中的自签名SSL 证书引起的。创建SSL证书的命令如下:

 $ mkdir certs
 $ openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
  -keyout certs/key.pem -out certs/cert.pem

Nginx配置如下,我想删除或注释掉ssl_certificate部分,重新​​加载。但是我发现我无法访问该站点。 添加 ssl_certificate 部分后,它就可以工作了。但是仍然有警告页面。 如何处理这个问题。

    server {
    # listen on port 443 (https)
    listen 443 ssl;
    server_name _;
    # location of the self-signed SSL certificate
    ssl_certificate /home/ubuntu/microblog2/certs/cert.pem;
    ssl_certificate_key /home/ubuntu/microblog2/certs/key.pem;

    location / {
        # forward application requests to the gunicorn server
        proxy_pass http://127.0.0.1:8000;
        proxy_redirect off;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
    location /static {
        # handle static files directly, without forwarding to the application
        alias /home/ubuntu/microblog2/static;
        expires 30d;
} }

最佳答案

为了从您的设置中删除证书,您需要将配置返回到不支持 SSL 的端口 80。因此,删除 listen 443 ssl ssl_certificate 行,并替换为 listen 80 only。

获得正确的证书后,上传配置中显示的证书文件后,您可以返回此配置。

关于python - 如何删除在 AWS ubuntu 服务器中创建的自签名 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48368466/

相关文章:

python - 为什么python的subprocess.call是这样实现的?

python - 删除 gtk.Table 中的小部件?

linux - 连续在 AWS EC2 linux AMI 上运行 perl 脚本

amazon-web-services - go-sdk上s3前缀可以去掉吗?

php - 从浏览器直接上传到S3(亚马逊)和https麻烦

ubuntu - perf annotate 并不总是给出输出

ubuntu - CURL 返回 (35) OpenSSL SSL_connect : SSL_ERROR_SYSCALL

python - 使用 SQL Alchemy 和 pymssql 指定故障转移合作伙伴

mysql - 安装多个 Moodle 包

python - 如何使用谷歌翻译将乌尔都语单词音译为罗马乌尔都语