在nginx.conf配置文件中添加:
server {
listen 80;
server_name *.easex.cn;
return 301 https://$http_host$request_uri;
}
在nginx.conf文件或者子配置文件中添加:
server {
listen 443 ssl http2;
server_name *.easex.cn;
ssl_certificate cert/easex.cn/fullchina.cer;
ssl_certificate_key cert/easex.cn/easex.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSV1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;
access_log logs/easex.cn_access.log;
error_log logs/easex.cn_error.log;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_pass http://tomcat9/;
}
}
*.easex.cn为域名,当访问网站时,监听到80端口,那么NGINX会将80端口301重定向到https,也就是443端口监听的服务。
服务器需要打开80和443端口。
网友评论