void

Nginx + SSL 配置

安装nginx之前先安装 openssl 和 openssl-devel
编译nginx时使用 --with-http_ssl_module 就可以支持SSL了

然后需要生成服务器证书,没钱就用openssl自己作一个

   openssl req -new -x509 -nodes -out eglic.crt -keyout eglic.key

增加一个虚拟主机

server {
 listen 443;
 ssl on;
 ssl_certificate  /opt/eglic.crt;
 ssl_certificate_key /opt/eglic.key;
 server_name 
www.eglic.com;
        charset gb2312;
 index  index.php index.html index.htm;
 root   /var/www/eglic;
 location / {
  index  index.php index.html index.htm;
  rewrite ^/show-([0-9]+)-([0-9]+)\.html$ /index.php?action=show&id=$1&page=$2 last;
  rewrite ^/category-([0-9]+)-([0-9]+)\.html$ /index.php?action=index&cid=$1&page=$2 last;
  rewrite ^/archives-([0-9]+)-([0-9]+)\.html$ /index.php?action=index&setdate=$1&page=$2 last;
  rewrite ^/(archives|search|reg|login|index|links)\.html$ /index.php?action=$1 last;
  rewrite ^/(comments|tagslist|trackbacks|index)-([0-9]+)\.html$ /index.php?action=$1&page=$2 last;
 }
 location ~ .*\.php?$
 {
  fastcgi_pass   127.0.0.1:10086;
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
  fastcgi_param  QUERY_STRING       $query_string;
  fastcgi_param  REQUEST_METHOD     $request_method;
  fastcgi_param  CONTENT_TYPE       $content_type;
  fastcgi_param  CONTENT_LENGTH     $content_length;
  fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  fastcgi_param  REQUEST_URI        $request_uri;
  fastcgi_param  DOCUMENT_URI       $document_uri;
  fastcgi_param  DOCUMENT_ROOT      $document_root;
  fastcgi_param  SERVER_PROTOCOL    $server_protocol;
  fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  fastcgi_param  SERVER_SOFTWARE    eglic/$nginx_version;
  fastcgi_param  REMOTE_ADDR        $remote_addr;
  fastcgi_param  REMOTE_PORT        $remote_port;
  fastcgi_param  SERVER_ADDR        $server_addr;
  fastcgi_param  SERVER_PORT        $server_port;
  fastcgi_param  SERVER_NAME        $server_name;
  fastcgi_param  REDIRECT_STATUS    200;
 }
}


现在可以通过 https://www.eglic.com/访问我了!

posted on 2008-08-06 12:14 void 阅读(506) 评论(0)  编辑  收藏 所属分类: Nginx


只有注册用户登录后才能发表评论。


网站导航: