【nginx】nginx部署升级htpp+websocket访问

关注todo-step1和todo-step2就行了:

js 复制代码
user root;
......
http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	types_hash_max_size 2048;
	

	client_max_body_size 10240m;
	include /etc/nginx/mime.types;
	default_type application/octet-stream;

    # 配置websocket访问 *****************todo-step:1*****************
    map $http_upgrade $connection_upgrade { 
        default          keep-alive;  #默认为keep-alive 可以支持 一般http请求
        'websocket'      upgrade;     #如果为websocket 则为 upgrade 可升级的。
    }

	# 配置80访问gateway
	upstream gateway{
	server com.xxx.com:30000;
	}

	server {

		listen 80; # 监听端口
		server_name com.xxx.com; #配置域名或IP地址

		location / {
			proxy_pass  http://gateway/; # 将请求转发到backend_server服务器的地址
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade; #此处配置 上面定义的 *****************todo-step:2*****************
			proxy_set_header Connection $connection_upgrade;
		}

		location /xx/ {
			alias /xx/temp/; # 将请求转发到服务器的地址
			add_header Front-End-Https on;
			add_header 'Access-Control-Allow-Headers' '*';
			add_header 'Access-Control-Allow-Methods' '*';
			add_header 'Access-Control-Allow-Origin' $http_origin;
			add_header 'Access-Control-Allow-Credentials' 'true';
		}

	}

}
相关推荐
哲讯智能科技13 小时前
苏州SAP代理商:哲讯科技助力企业数字化转型
大数据·运维·人工智能
十五年专注C++开发13 小时前
Qt .pro配置gcc相关命令(三):-W1、-L、-rpath和-rpath-link
linux·运维·c++·qt·cmake·跨平台编译
qq_6285157613 小时前
Centos与RockLinux设置静态ip
linux·运维·centos
程序员老乔14 小时前
【Dify系列】【一】【安装与部署】【ubuntu22.04安装docker部署dify1.4.2】
运维·docker·容器
沧浪之水1201013715 小时前
linux常用命令
linux·运维·服务器
YUNYINGXIA15 小时前
Nginx+keepalived主从,双主架构
网络·nginx·keepalived
梦会实现15 小时前
无外接物理显示器的Ubuntu系统的远程桌面连接(升级版)
linux·运维·ubuntu·计算机外设
Hello.Reader15 小时前
NGINX 四层共享内存区同步模块实战 `ngx_stream_zone_sync_module`
运维·nginx
暗离子跃迁15 小时前
达梦数据库单机部署dmhs同步复制(dm8->kafka)
linux·运维·数据库·分布式·学习·kafka·达梦数据库
北城笑笑16 小时前
Server 11 ,⭐通过脚本在全新 Ubuntu 系统中安装 Nginx 环境,安装到指定目录( 脚本安装Nginx )
linux·运维·前端·nginx·ubuntu