首页 > Linux, Nginx > Nginx/Apache的SSL配置

Nginx/Apache的SSL配置

  1. 首先需要升级OpenSSL和OpenSSH。后者顺带升级下,并非必须。注意顺序,先SSL再SSH。

1
2
3
4
5
6
7
8
9
#cd /usr/local/src
#wget http://www.openssl.org/source/openssl-0.9.8e.tar.gz
#wget ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-4.6p1.tar.gz
#tar xzvf openssl-0.9.8e.tar.gz
#cd openssl-0.9.8e
#./config --prefix=/usr/local/openssl
#make
#make test
#make install
1
2
3
4
5
6
#cd ..
#tar xzvf openssh-4.6p1.tar.gz
#cd openssh-4.6p1
#./configure --prefix=/usr --with-pam --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man
#make
#make install

#ssh –V

查看版本。

  1. 接下来生成对应服务器的key/crt文件

1
[root@bbs ~]#openssl genrsa -des3 -out server.key 1024

这里会提示你输入一个密码。

根据Key生成一个CSR

1
[root@bbs ~]#openssl req -new -key server.key -out server.csr

自己给自己颁发一个证书

1
[root@bbs ~]# openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt

ok,保存好.crt和.key文件。.csr文件不需要了。

Apache使用的是.crt+.key文件。而nginx使用的是.pem+.key文件。
.pem文件很简单,直接把.crt和.key复制出来,粘贴到新的.pem文件里就行了。

Apache的配置。虚拟主机部分增加:

1
2
3
4
5
6
7
8
9
10
11
12
<VirtualHost bbs.nau.edu.cn:443>
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /data/certfile/server.crt
SSLCertificateKeyFile /data/certfile/server.key
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
ServerAdmin baalchina@nau.edu.cn
DocumentRoot /data/web/bbs
ServerName bbs.nau.edu.cn:443
</VirtualHost>

如果是nginx,那么:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
   listen       443;
   server_name  bbs.nau.edu.cn;
 
   if ($uri !~* "/logging.php$") {
   rewrite ^/(.*)$ http://$host/$1 redirect;
   }
 
   ssl                  on;
   ssl_certificate      /data/certfile/server.pem;
   ssl_certificate_key  /data/certfile/server.key;
   ssl_session_timeout  5m;
   ssl_protocols  SSLv2 SSLv3 TLSv1;
   ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
   ssl_prefer_server_ciphers   on;
   }

其他部分和http server是一样的。

分类: Linux, Nginx 标签: , , ,
  1. 2009年11月26日21:56 | #1

    Всем привет! Вот нашел в инете сайт http://www.magellan-21.net на нем все о [url=http://magellan-21.net]колготках[/url] чулках носках и нижним белье

  2. 2010年4月6日13:27 | #2

    http://bfmgazeta.ru Новости о бизнесе

  3. 2010年5月1日21:06 | #3

    Hi!!!

    This is my opening article here, i will come back as other as i can to validate other entries

    if you like flexibility, visit my new article
    [url=http://ezinearticles.com/?How-to-Become-More-Flexible&id=4002600]how to become more flexible[/url]

    bye!!

  4. 2010年6月14日15:27 | #4

    Hello,

    You site is very good.

    Nice content.

    Gretz.

  5. 2010年7月4日01:54 | #5

    NiksHind 6 I consider, that you are mistaken. Let's discuss.

    _____________
    lavetra
    real
    8

  6. 2010年7月9日16:28 | #6

    Hello everyone ..
    Great work and nice share!
    penis enlargement
    penis enlargement
    [url=http://www.buypenisenlargement.com]penis enlargement[/url]
    [url=http://penisenlargementkey.com]penis enlargement[/url]

  1. 本文目前尚无任何 trackbacks 和 pingbacks.