技术文档

CentOS 6 配置 Nginx 80自动跳转至443端口(http协议自动跳转至https协议) – HTTPS SSL 教程

1、yum 安装 nginx

配置 yum 源: 在 /etc/yum.repos.d/ 新建文件 nginx.repo ,写入如下内容:

CentOS 6 配置 Nginx 80自动跳转至443端口(http协议自动跳转至https协议) – HTTPS SSL 教程

name=nginx repobaseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1

安装:

yuminstallnginx-y

2、配置 80 跳转 443(访问http协议时自动跳转到https协议)编辑 /etc/nginx/conf.d/default.conf 文件修改如下:

server{ listen80; server_namenote.; rewrite^(.*)$https://$server_name$1permanent; access_log/var/log/nginx/host.http2https.access.log main; }

3、https反向代理(https协议的访问实际是访问所代理的9800端口)

server{ listen443; server_namelee.; sslon; ssl_certificate/etc/pki/tls/certs/lee.crt; ssl_certificate_key/etc/pki/tls/certs/lee.key; access_log/var/log/nginx/host.note.access.logmain; location/{ proxy_passhttp://127.0.0.1:9800; resolver_timeout30s; proxy_set_headerHost$http_host; proxy_set_headerX-Real-IP$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; proxy_set_headerX-Forwarded-Protohttps; proxy_redirectoff; } }

 

 

©2020-2024   万云SSL证书  (www.sslssl.com.cn)  万云科技   豫ICP备2020034358号-10