为什么nginx只提供http地址服务?

为什么nginx只提供http地址服务?

虽然我是 nginx 新手,但几乎所有东西似乎都运行良好。唯一的问题是,当我尝试使用 https:// 地址访问该地址时,需要 30-60 秒才能加载,但输入 http:// 时只需几秒钟即可重定向和加载 https://。

我确信这与我的 nginx conf 文件有关,但看不出问题出在哪里,希望能得到一些新的看法。引用我的 ssl 上下文时是否存在问题?

    upstream custodian {
  # The web application.
  server custodian:8000;

server {
  listen 80;
  server_name custodian.fund www.custodian.fund;
  root /var/www/letsencrypt;

  location /.well-known/acme-challenge/ {
    default_type "text/plain";

    try_files $uri =404;
  }

  location / {
    return 301 https://custodian.fund$request_uri;
  }
}

server {

  listen 443 ssl;
  server_name custodian.fund;

  # Static asset path, which is read from the custodian container's VOLUME.
  root /custodian/static;

  # Ensure timeouts are equal across browsers and raise the max content-length size.
  keepalive_timeout 60;
  client_max_body_size 5m;

  # SSL goodness.
  ssl                       on;
  ssl_certificate /etc/ssl/private/custodian.fund.pem;
  ssl_certificate_key /etc/ssl/custodian.fund.key;
  ssl_trusted_certificate /etc/ssl/private/custodian.fund.pem;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
  ssl_dhparam /etc/ssl/dhparam.pem;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:50m;
  ssl_session_timeout 5m;
  ssl_stapling on;
  ssl_stapling_verify on;
  resolver 8.8.8.8;
  resolver_timeout 5s;
  add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";


 # ssl_certificate /etc/ssl/certs/productionexample.crt;
 # ssl_certificate_key /etc/ssl/private/productionexample.key;


  # Disallow access to hidden files and directories.
  location ~ /\. {
    return 404;
    access_log off;
    log_not_found off;
  }

  # Allow optionally writing an index.html file to take precedence over the upstream.
  try_files $uri $uri/index.html $uri.html @custodian;

  # Attempt to load the favicon or fall back to status code 204.
  location = /favicon.ico {
    try_files /favicon.ico = 204;
    access_log off;
    log_not_found off;
  }

  # Load the web app back end with proper headers.
  location @custodian {
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;

答案1

问题出在您的 DNS 上。您为主机名 custodian.fund 配置了四个完全不同的 IP 地址,但实际上只有其中一个是您的网站托管地。

custodian.fund has address 107.161.23.204
custodian.fund has address 128.199.121.161
custodian.fund has address 209.141.38.71
custodian.fund has address 192.161.187.200

其余三个地址无法连接,因为其中任何一个地址都没有任何内容。

要解决此问题,请从 DNS 记录中删除三个不正确的条目。

相关内容