使用nginx 1.8.0,drupal 7站点工作配置在Ubuntu 14.04上设置SSL?

时间:2016-01-04 18:28:32

标签: ubuntu ssl nginx drupal

我需要配置:

使用 nginx 1.8.0, drupal 7 网站在ubuntu 14.04上设置 SSL

买了一个ssl,在服务器上实现了所有步骤(copy-conctenate文件)并在config下面应用: 在 etc / nginx / sites-available / drupal 上没有运气 - 找不到网站。

server {
  listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;

  listen 443 ssl;

  root /var/www/html/drupal;
  index index.php index.html index.htm;

  server_name www.MYSITE.com;
  ssl_certificate /etc/nginx/ssl/public.crt;
  ssl_certificate_key /etc/nginx/ssl/mykey.key;

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
      root /usr/share/nginx/html;
  }

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

   location = /robots.txt {
     allow all;
     log_not_found off;
     access_log off;
   }

   location ~ \..*/.*\.php$ {
     return 403;
   }

   location ~ ^/sites/.*/private/ {
     return 403;
   }

   location ~ (^|/)\. {
     return 403;
   }

   location / {
     try_files $uri @rewrite;
   }

   location @rewrite {
     rewrite ^ /index.php;
   }

   location ~ \.php$ {
     fastcgi_split_path_info ^(.+\.php)(/.+)$;
     include fastcgi_params;
     fastcgi_param SCRIPT_FILENAME $request_filename;
     fastcgi_intercept_errors on;
     fastcgi_pass unix:/var/run/php5-fpm.sock;
   }

   location ~ ^/sites/.*/files/styles/ {
     try_files $uri @rewrite;
   }

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

我需要修理什么?

1 个答案:

答案 0 :(得分:0)

忘了包含我的解决方案。 我成功了以下设置: 我还必须在Drupal settings.php上设置基本网址为 https ://www.example.com

server {
listen 80;
server_name www.example.com;
rewrite ^/(.*) https://www.example.com/$1 permanent;
}  

server {

listen 443 ssl;

root /var/www/html/mydrupaldirectory;
index index.php index.html index.htm;

server_name www.mysite.com;
ssl_certificate /etc/ssl/certs/public.crt;
ssl_certificate_key /etc/ssl/certs/mykey.key;

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
  root /usr/share/nginx/html;
}