Nginx 支持SSL加密代理 具体配置方法
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Nginx 支持SSL加密代理具体配置方法
一、安装nginx时,需要按照如下方式编译:
./configure --prefix=/home/nginx --with-md5=/usr/lib --with-sha1=/usr/lib --with-cc-opt="- I /usr/include/pcre -I /usr/include/openssl" --with-http_ssl_module make -j10
make install
二、具体配置
1、修改监听端口【https监听端口为443】;
listen 443;#ssl端口
listen 80;#用户习惯用http访问,加上80;
2、SSL 配置
upstream cdn_ {
server 192.168.100.2:80;
}
server {
server_name cdn_
include port.conf;
ssl on;
ssl_certificate ${nginx_install_dir}/conf/server.crt
ssl_certificate_key ${nginx_install_dir}/conf/server.key
error_page 497 "https://$host$uri?$args";
location / {
proxy_pass https://cdn_
include proxy.conf;
auth_basic "status";
auth_basic_user_file trac.passwd;
}
}
备注:
auth_basic "status";指定认证方式为htpasswd类型,auth_basic_user_file指定password文件为trac.passwd,对应${nginx_install_dir}/conf/trac.passwd。htpasswd是apache里的一个小工具,apt-get install apache2-utils后可以得到它,或者干脆就在这里创建:/htpasswd.php,把生成结果贴到trac.passwd里就可以了。