【问题标题】:Ubuntu/Nginx SSL certificate not workingUbuntu/Nginx SSL 证书不起作用
【发布时间】:2015-08-20 19:46:22
【问题描述】:

我在使用 NGINX/Nodejs 的 ubuntu 服务器上安装 SSL 证书时遇到问题。

在我拥有的 /etc/nginx/sites-enable/website 文件上

server {

  listen *:443 default_server ssl;
  listen 80;

  ssl_certificate_key /etc/ssl/myserver.key;
  ssl_certificate /etc/sscl/gd_bundle-g2-g1.crt;

  server_name  XXX.example.io;

  root /var/www/example/public/;

  client_max_body_size 100M;
  open_file_cache max=200000 inactive=20s;
  open_file_cache_valid 30s;
  open_file_cache_min_uses 2;
  open_file_cache_errors on;


  error_log /var/log/nginx/example_error.log warn;

  try_files $uri @example2;

  log_not_found on;

  log_subrequest on;

  location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 1d;
  }

  location @example2 {
    proxy_pass http://record;
  }


}

当我 netstat 查看端口 443 是否被监听时(netstat -antlp)

tcp        0      0 0.0.0.0:22              0.0.0.0:*              LISTEN      1022/sshd       
tcp        0      0 0.0.0.0:3000            0.0.0.0:*              LISTEN      19976/nodejs    
tcp        0      0 0.0.0.0:8000            0.0.0.0:*              LISTEN      30164/nodejs    
tcp        0      0 0.0.0.0:80              0.0.0.0:*              LISTEN      5656/nginx           
.......................

tcp6       0      0 :::22                   :::*                   LISTEN      1022/sshd 

关于为什么 NGINX 甚至不监听端口 443 的任何想法?我已经在 AWS 上打开它。

【问题讨论】:

  • 错误日志中有什么内容吗?

标签: ssl nginx


【解决方案1】:

我已经设法解决了这个问题,缺少 ;像往常一样,谢谢你的回复

【讨论】:

  • 继续并将其标记为正确答案,以便可以关闭
【解决方案2】:

我还建议不要在同一个配置中同时监听 80 和 443 端口。我建议设置服务器重定向,例如

server {
   listen 80;
   server_name endyourif.com www.endyourif.com;
   return 301 https://www.endyourif.com$request_uri;
}

Setting up SSL with nginx including redirects from non HTTPS traffic

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-24
    相关资源
    最近更新 更多