【问题标题】:After SSL Conf. returning "welcome to nginx!"在 SSL 会议之后。返回“欢迎使用 nginx!”
【发布时间】:2018-12-24 14:09:53
【问题描述】:

这里是 Nginx 菜鸟,我确实浏览了所有以前的帖子,但找不到任何特定于我的情况的内容。

我正在尝试在 nginx 上安装商业 SSL 证书。使用以下内容配置etc/nginx/sites-available/myapp 后:

server {
    listen 80;
    server_name example.come www.example.com;
    rewrite ^/(.*) https://example.com/$1 permanent;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/user/example.com;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/djangodeploy/example.com/rex.sock;
    }
}

server {
    listen 443 ssl;
    server_name example.com www.example.come;
    ssl_certificate /home/user/example.com.chained.crt;
    ssl_certificate_key /home/user/example.com.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GC$
    ssl_prefer_server_ciphers on;
}

检查语法后一切正常。 https 运行良好,但它并没有为实际网站提供服务,而是返回“欢迎使用 nginx!”

我还在 /etc/nginx/nginx.conf 中配置了 http 指令以包含:

http {
      ssl_certificate /home/user/example.com.chained.crt;
      ssl_certificate_key /home/user/example.com.key;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: $
      ssl_prefer_server_ciphers on;

我听说 gzip 会导致问题,我应该禁用它吗?

任何帮助将不胜感激!

【问题讨论】:

  • 更好的是在 https 上为应用程序提供服务并从 http 重定向到 https。

标签: django ssl nginx ubuntu-16.04


【解决方案1】:

HTTPS 服务器块不会代理到您的应用程序,因此您需要将 location / 块添加到它,最终如下:

server {
    listen 443 ssl;
    server_name example.com www.example.come;
    ssl_certificate /home/user/example.com.chained.crt;
    ssl_certificate_key /home/user/example.com.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GC$
    ssl_prefer_server_ciphers on;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/djangodeploy/example.com/rex.sock;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2022-11-13
    • 2012-05-07
    • 2012-02-05
    相关资源
    最近更新 更多