Ubuntu / Nginx SSL证书不起作用

时间:2015-08-20 19:46:22

标签: ssl nginx

我在使用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上打开了它。

2 个答案:

答案 0 :(得分:0)

我设法解决了这个问题,一个失踪;像往常一样,谢谢你的回复

答案 1 :(得分:0)

我也建议不要在同一配置中同时监听端口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