Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4176648
  • 博文数量: 601
  • 博客积分: 15410
  • 博客等级: 上将
  • 技术积分: 6884
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 08:11
个人简介

独学而无友,则孤陋而寡闻!

文章分类

全部博文(601)

文章存档

2020年(1)

2018年(4)

2017年(7)

2016年(42)

2015年(25)

2014年(15)

2013年(36)

2012年(46)

2011年(117)

2010年(148)

2009年(82)

2008年(37)

2007年(41)

分类: 系统运维

2009-10-05 19:11:27

tell vistors to add your site into exception, or go to buy a cerficate :D

细心的童鞋已经注意到我这里最近开了https, 起因很简单, 公司这两天搞情报安全强化, 监视一切网络活动. 不想把整个后台就这么赤果果的展示给他们看 (虽然我认为他们铁定看不懂), 所以不得已启用了https

1. 编译nginx

# ./configure --with-sha1=/usr/lib \
--with-md5=/usr/lib \
...
--with-http_ssl_module

2. 生成dummy证书

# openssl genrsa -des3 -out cert.key 1024
# openssl req -new -key cert.key -out cert.csr
# openssl rsa -in cert.key -out cert.key
# openssl x509 -req -days 365 -in cert.csr -signkey cert.key -out cert.pem

* 注: 如果没有做openssl rsa -in cert.key -out cert.key这一步, nginx会在启动时提示输入密码, 导致server无法自动启动

3. 配置nginx

最简单的, 把现有配置文件的server部分复制一份, 然后做以下修改

server {
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/cert.pem;
ssl_certificate_key /usr/local/nginx/conf/cert.key;
...
}

habari会在$_REQUEST中检查HTTPS的值, 所以在HTTPS没有设置或者是设置为off的情况下, 即使以https://的scheme访问, 代码中生成的链接仍然是http而不是https, 所以我们需要在cgi参数中加入https项, 如下:

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/habari$fastcgi_script_name;
fastcgi_param HTTPS on;
include fastcgi_params;
}

至此, 重启nginx.

阅读(2434) | 评论(0) | 转发(0) |
0

上一篇:Typo3常用缩写

下一篇:habari推荐的nginx配置

给主人留下些什么吧!~~