通过nginx实现对普通的网站ssl加密
nginx.conf
#user nobody;
worker_processes 3;
worker_cpu_affinity 001 010 100;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
server {
#对80端口进行转发到443.
listen 80;
rewrite ^(.*)$ https://$host:443/$1 permanent;
}
# HTTPS server
#
server {
listen 443 ssl;
server_name localhost;
#配置证书。
ssl_certificate /usr/local/nginx/key/c.pem; #公钥 openssl req -new -x509 -days 2000 -key c.key -out c.pem
ssl_certificate_key /usr/local/nginx/key/c.key;#私钥 openssl genrsa -out c.key 2048
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
#后端web服务器地址。
proxy_pass http://192.168.0.151;
}
}
}
- 点赞
- 收藏
- 关注作者
评论(0)