【问题标题】:Set up SSL on Ubuntu 14.04 with nginx 1.8.0, drupal 7 site working configuration?在 Ubuntu 14.04 上使用 nginx 1.8.0、drupal 7 站点工作配置设置 SSL?
【发布时间】:2016-01-04 18:28:32
【问题描述】:

我需要一个配置:

在具有 nginx 1.8.0、drupal 7 站点的 ubuntu 14.04 上设置 SSL

购买了一个 ssl,在服务器上实现了所有步骤(复制连接文件)并应用于以下配置: 在 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;
   }
}

我需要解决什么问题?

【问题讨论】:

    标签: ubuntu ssl nginx drupal


    【解决方案1】:

    忘记包含我的解决方案。 我成功完成了以下设置: 我还必须在 Drupal settings.php 中将基本 url 设置为 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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 2012-10-15
      • 1970-01-01
      相关资源
      最近更新 更多