• 在nginx环境下搭建基于ssl证书的websocket服务转发,wss


    1、证书准备

    本地调试,可以安装自签名证书,安装方法参考https本地自签名证书添加到信任证书访问

    2、修改配置文件

    将上面的配置文件拷贝到conf目录,添加或者修改节点如下

    # HTTPS server    
        server {
            listen       443 ssl;
            server_name  www.aaa.com;
    
        ssl on;
            ssl_certificate      www.aaa.com+5.pem;
            ssl_certificate_key  www.aaa.com+5-key.pem;
    
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
    
            ssl_ciphers  HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers  on;
    
            #charset koi8-r;
            access_log logs/aiPlatform/access_log;
            error_log  logs/aiPlatform/error_log   error;
            
            location / {            
                proxy_pass  http://127.0.0.1:8111;
                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;
            }
            
            location /api/asr {
                proxy_pass http://127.0.0.1:81/api/asr;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade"; 
            }
            
            location /api/tts {
                proxy_pass http://127.0.0.1:81/api/tts;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade"; 
            }                
        } 

    以上会将基于ssl证书的websocket请求按照请求地址转发到本地服务的81端口上。

    wss://www.aaa.com/api/asr转发到 127.0.0.1:81/api/asr

    wss://www.aaa.com/api/tts转发到 127.0.0.1:81/api/tts

  • 相关阅读:
    easyui combo自动高度(下拉框空白问题)
    log4net
    asp.net mvc 生成条形码
    Kubernetes 初探
    美国最顶级的投资机构在关注什么
    Ansible--01
    第一章 进入java的世界
    正则表达式
    zabbix接口调用注意事项--Python
    Docker+K8S实践
  • 原文地址:https://www.cnblogs.com/passedbylove/p/12060771.html
Copyright © 2020-2023  润新知