【问题标题】:Nginx configuration issue with https on windowsWindows上https的Nginx配置问题
【发布时间】:2020-12-14 07:35:27
【问题描述】:

我正在尝试将我的 react 应用程序部署到 nginx 服务器。 Http 配置工作正常,但 https 不工作。这是我的配置文件。

events {
    worker_connections  1024;
}  

http {
    server {
      listen 80;
      server_name example.com;
      root D:\\path-to-build\\build;
      index index.html;
     

      location / {
        try_files $uri /index.html =404;
      }
      }

    server {
        listen              443 ssl;
        server_name         example.com;
        keepalive_timeout   70;

        ssl_certificate     C:\\Certbot\\live\\domain\\fullchain.pem;
        ssl_certificate_key C:\\Certbot\\live\\domain\\privkey.pem;
        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers         HIGH:!aNULL:!MD5;
        #...
        access_log D:\\path-to-log\\access.log;
        error_log D:\\path-to-log\\error.log;
        root D:\\path-to-build\\build;
        index index.html;
        location / {
          try_files $uri /index.html =404;
         }
    }
}

【问题讨论】:

  • “但是https不起作用”是什么意思,有错误?无法连接?
  • 当我尝试使用 https.example.com URL 进行访问时,出现错误“连接已超时”。我的服务器配置是否有效?

标签: reactjs nginx https configuration


【解决方案1】:

您的配置文件看起来不错。但是在您的 SSL 服务器配置中,我没有看到对 rootindex 指令的任何引用。

也将其添加到您的 SSL 服务器:

root D:\\path-to-build\\build;
index index.html;

同样作为错误暗示(“连接已超时”),您能否尝试将值更改为keepalive_timeout 70s; 请注意,默认值为 75 秒。

【讨论】:

  • 我尝试在 ssl 服务器中添加它,但它也无法正常工作。
  • 您可以尝试更改 keepalive_timeout 以使用秒数吗?我不确定 70 是什么意思,但使用 70 会更安全 :)
  • 增加超时后同样的问题。
  • 你能尝试在ssl_protocols 中只使用TLSv1.2 还是只使用TLSv1.1
  • 你也可以运行 nginx -V 并在此处注释输出,它将打印 NGINX 版本,编译器版本和配置参数。
【解决方案2】:

仅配置正确,但在我的服务器机器中 443 帖子未对外开放。这就是我连接超时的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-14
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    • 2016-08-23
    • 2017-06-08
    • 2012-03-17
    相关资源
    最近更新 更多