nginx支持ssl的方法:
在nginx配置文件中添加支持ssl傳輸協議,例如:
shell> vim /usr/local/nginx/conf/nginx.conf------------------------------------------------
user apache apache;
worker_processes 2;
error_log logs/error_nginx.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
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"';
access_log logs/access_nginx.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
server {
listen 443;
server_name www.mlszssj.com;
charset uft-8;
access_log logs/www.access.log main;
root /var/www/html;
location / {
index index.html index.htm;
}
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/client.pem;
ssl_certificate_key /usr/local/nginx/conf/ssl/client.key;
}
}
--------------------------------------------------------
#上面的配置只支持http://www.mlszssj.com 訪問,因為監聽端口只開了443端口,普通的http協議的80端口并未開放
#要開放http和https,再加上下面這一條server
------------------------------------------------
server {
listen 80;
server_name www.mlszssj.com;
charset uft-8;
access_log logs/www.access.log main;
root /var/www/html;
location / {
proxy_pass http://10.10.54.150:1500;
}
}
#當用戶使用http協議瀏覽該網站時,自動跳轉到10.10.54.150:1500上
------------------------------------------------