正在加载...

Nginx + SSL 配置

[ 2009/05/08 18:40 | by selboo ]

安装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  selboo.com.cn;
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;
}
}

Tags:
,
发表评论
表情
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]