nginx配置SSL模块
下载nginx源码包
wget http://nginx.org/download/nginx-1.5.9.tar.gz
解压 :
tar -zxvf nginx-1.5.9.tar.gz
进入nginx文件夹
cd nginx-1.5.9
进行编译把一些插件编译安装 。这个一定要加 --with-http_ssl_module
./configure --prefix=/home/soft/nginx \
--conf-path=/home/soft/nginx/etc/nginx.conf \
--user=nginx --group=nginx \
--error-log-path=/home/soft/nginx/nginxlog/error.log \
--http-log-path=/home/soft/nginx/nginxlog/access.log \
--pid-path=/home/soft/nginx/pids/nginx.pid \
--lock-path=/home/soft/nginx/locks/nginx.lock \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/home/soft/nginx/tmp/client \
--http-proxy-temp-path=/home/soft/nginx/tmp/proxy \
--http-fastcgi-temp-path=/home/soft/nginx/tmp/fastcgi \
--http-uwsgi-temp-path=/home/soft/nginx/tmp/uwsgi \
--http-scgi-temp-path=/home/soft/nginx/tmp/scgi
执行 make & make install
server {
listen 80;
listen 443 ssl;
server_name 你的域名;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#这个可以是项目jar包的端口,根据自身的情况修改
proxy_pass http://127.0.0.1:20890;
}
#这个文件在nginx/conf 下面 安装自定义配置
ssl_certificate cert/3161394_wechata.ydc.haoxincm.com.pem;
#这个文件在nginx/conf 下面 安装自定义配置
ssl_certificate_key cert/3161394_wechata.ydc.haoxincm.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
}
重启nginx,即可
密匙证书在够买的服务器上申请,有免费版的使用
本文详细介绍如何在Nginx中配置SSL模块,包括下载源码包、编译安装及配置HTTPS监听,确保网站安全传输。同时,提供具体配置代码示例,帮助读者快速上手。
838

被折叠的 条评论
为什么被折叠?



