nginx 反向代理配置 nginx配置https Myth丶恋晨 2021-06-24 15:58 724阅读 0赞 # **nginx反向代理配置 ** nginx配置https # ## 配置这个转发还是比较简单的,外加https访问,只需要自己获取到相关的SSL证书即可 ## ## 特别注意,需要先合并证书.crt、.cer文件 ## #后台转发给tomcat upstream yuming_server{ server www.yuming.com:8080; } server{ listen 80; listen 443 ssl; server_name www.yuming.com; #ssl on; ssl_certificate D:/phpStudy/nginx/ssl/yuming.crt; ssl_certificate_key D:/phpStudy/nginx/ssl/yuming.key; index index.html index.htm index.php; root D:/data/app.gzsh; location ~^/APP/ { expires 0d; #缓存作用(30秒/30分钟/2小时/30天) } location / { proxy_pass http://yuming_server; proxy_cookie_path https://www.yuming.com/ /; proxy_store off; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; #deny all; } access_log D:/data/access.log; } ## 说明:https需要三个文件 下面作为说明 ## ## Nginx 部署SSL证书 (特别注意下面加红内容,需要先合并.crt、.cer文件) ## \#需将.cer 中的内容复制到.crt文件头部,中间不要有空 a. 查看nginx是否开启ssl 执行命令: nginx安装目录/sbin/nginx -V, 查看命令结果中是否包含"--with-http\_ssl\_module",否则请先安装ssl模块 b. 配置证书到对应的站点 编辑站点对应的站点配置文件,新增或修改如下内容 server \{ listen 443 ssl; \#将原来的80 修改为443 ... root /www/web/xxxx/public\_html; ssl\_certificate 证书文件路径/\_www.domain.com.crt; \#需将\_www.domain.com.cer 中的内容复制到这个文件头部,中间不要有空行 ssl\_certificate\_key 证书文件路径/\_www.domain.com.key; \#证书密钥文件 ssl\_protocols TLSv1 TLSv1.1 TLSv1.2; ssl\_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL; ... \}
还没有评论,来说两句吧...