Nginx 代理https
生活随笔
收集整理的這篇文章主要介紹了
Nginx 代理https
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
利用Nginx 代理https 轉到訪問本機 http 的訪問,首先需要有證書:手頭開發環境下使用了自簽名工具生成pfx證書文件;
接著找一個在線的證書格式轉化工具,將pfx格式證書提前公鑰和私鑰。
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;}?這個過程中提示報錯:
ERR_SSL_VERSION_OR_CIPHER_MISMATCH:
注意ssl協議的版本:例如修改成 ssl_protocols TLSV1 TLSv1.1 TLSv1.2;
另外一個錯誤:PEM_read_bio_X509_AUX() failed (SSL: error:0906D06C )
是因為證書內容錯誤,重新生成后錯誤消失;
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
啟動Nginx : start nginx
測試驗證:
?
總結
以上是生活随笔為你收集整理的Nginx 代理https的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IP和MAC地址绑定的好处和作用
- 下一篇: Centos8 yum安装Nginx