Nginx配置https跳转http项目示例
打开nginx.conf,放开443端口Server的注释并修改如下:(注意两个ssl证书文件放到conf目录下和nginx.conf同级),这样的话访问https://xxx.xxxxxxx.com/classstar/就会转发到以8081端口启动的普通http服务器项目的根目录。
server {
listen 443 ssl;
server_name xxx.xxxxxxx.com;
ssl_certificate 1_xxx.xxxxxxx.com_bundle.crt;
ssl_certificate_key 2_xxx.xxxxxxx.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
location /classstar{
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:8081;
}
}