nginx转发wss

做了一个tp6+swoole的项目,没找到swoole开启ssl的资料,想起以前做过转发可以实现

就新建了一个站,然后转发到swoole的端口,也能实现wss的访问

下面是配置文件

upstream wss{
    server 127.0.0.1:8282;
}
server
{
    listen 80;
	listen 443 ssl http2;

    #其他配置代码

    location / {
        add_header Access-Control-Allow-Origin *;
        proxy_redirect off;
        proxy_pass http://wss;
        proxy_set_header Host $host;
        proxy_set_header X-Real_IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;  
        proxy_set_header Connection "Upgrade";  
    }    
}

你可能感兴趣的:(nginx反向代理,ssl,swoole)