Laravel Forge Nginx配置SSL

时间:2014-11-08 09:41:15

标签: php ssl nginx server laravel-forge

我通常不会发布问题,直到我在互联网上研究它为止。我使用Laravel Forge创建CSR,添加证书,激活它,使用以下资源编辑Nginx配置:

https://stackoverflow.com/questions/26192839/laravel-forge-ssl-certificate-not-working

^ curl https://domain.com返回数据

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

server {
  listen 443 ssl;
  server_name example.com www.example.com;
  root /home/forge/example.com/public;

  # FORGE SSL (DO NOT REMOVE!)
  ssl_certificate /etc/nginx/ssl/vgport.com/3042/server.crt;
  ssl_certificate_key /etc/nginx/ssl/vgport.com/3042/server.key;

  index index.html index.htm index.php;

  charset utf-8;

  location / {
      try_files $uri $uri/ /index.php?$query_string;
  }

  location = /favicon.ico { access_log off; log_not_found off; }
  location = /robots.txt  { access_log off; log_not_found off; }

  access_log off;
  error_log  /var/log/nginx/default-error.log error;

  error_page 404 /index.php;

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }

  location ~ /\.ht {
      deny all;
  }
}

我做'服务nginx重启'在命令行中,转到/var/log/nginx/error.log并看到以下错误:

'conflicting server name "" on 0.0.0.0:80, ignored'
'conflicting server name "www.domain.com" on 0.0.0.0:80, ignored'

当我访问domain.com时,它会被重定向到https://domain.com并且该网页有一个重定向循环'。显然,Nginx重定向并不是以某种方式工作,但我已经完成了所有步骤。

请让我知道我应该发布哪些其他错误日志和信息来解决此问题。任何帮助将不胜感激,提前感谢。

2 个答案:

答案 0 :(得分:3)

好的,所以问题比我想象的要简单。我正在使用免费的cloudflare dns指向哪些不支持ssl。我切换到使用namescheap dns,它开始工作。

答案 1 :(得分:1)

在花了一些时间研究nginx后,我想添加一个证书,你必须手动按下"激活它"一旦下载。