Nginx 代理https
利用Nginx 代理https 轉(zhuǎn)到訪問(wèn)本機(jī) http 的訪問(wèn),首先需要有證書(shū):手頭開(kāi)發(fā)環(huán)境下使用了自簽名工具生成pfx證書(shū)文件;
接著找一個(gè)在線的證書(shū)格式轉(zhuǎn)化工具,將pfx格式證書(shū)提前公鑰和私鑰。
Nginx配置如下:
server {#listen 80;listen 443 ssl;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;e ssl_certificate cert/nacos.crt; ssl_certificate_key cert/nacos.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;charset utf-8;location / {proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $http_host;#root html;#index index.html index.htm;proxy_pass http://localhost:5002/;#proxy_pass http://127.0.0.1:8848/nacos;}?這個(gè)過(guò)程中提示報(bào)錯(cuò):
ERR_SSL_VERSION_OR_CIPHER_MISMATCH:
注意ssl協(xié)議的版本:例如修改成 ssl_protocols TLSV1 TLSv1.1 TLSv1.2;
另外一個(gè)錯(cuò)誤:PEM_read_bio_X509_AUX() failed (SSL: error:0906D06C )
是因?yàn)樽C書(shū)內(nèi)容錯(cuò)誤,重新生成后錯(cuò)誤消失;
Nginx 配置文件檢查:nginx -t;
nginx: the configuration file D:\nginx-1.22.1/conf/nginx.conf syntax is ok
nginx: configuration file D:\nginx-1.22.1/conf/nginx.conf test is successful
啟動(dòng)Nginx : start nginx
測(cè)試驗(yàn)證:
?
總結(jié)
以上是生活随笔為你收集整理的Nginx 代理https的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: IP和MAC地址绑定的好处和作用
- 下一篇: Centos8 yum安装Nginx