一、先申请和购买https证书
这里我就不用多说了,这个网上有许多资料对着操作申请就可以了。
二、需要检查你当前服务器安装的Nginx是否支持SSL模块,如果不支持需要开启
1、通过以下命令来查看是否支持SSL模块
/usr/local/nginx/sbin/nginx -V
输出的信息,如下:
configure arguments: --prefix=/usr/local/nginx
可见,只指定了一个安装路径,没有其他特殊的编译参数,表示目前是不支持SSL模块的。
2、我们可以通过如下命令开启SSL模块
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make
注意,此时千万不能手快直接 make install!
3.我们需要覆盖编译出来的nginx可执行程序,如下:
cp /usr/local/nginx/sbin/nginx ~/
cp objs/nginx /usr/local/nginx/sbin/
三、在nginx进行监听443端口,然后进行域名转发,例如,我的配置如下:
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $