当前位置:网站首页>Nignx configuring websocket

Nignx configuring websocket

2022-06-10 06:36:00 I have an FC

http {
    
	include       mime.types;
	default_type  application/octet-stream;
	sendfile        on;
	keepalive_timeout  65;
	server_names_hash_bucket_size 128;
	client_header_buffer_size 32k;
	large_client_header_buffers 4 32k;
	client_max_body_size 30m;
	tcp_nopush   on;
	log_subrequest on;
	tcp_nodelay on;
	gzip on;
	gzip_min_length 1k;
	gzip_buffers   4 16k;
	gzip_http_version 1.0;
	gzip_comp_level 2;
	gzip_types    text/plain application/x-javascript text/css application/xml;
	gzip_vary on;
	upstream www.cq.xxx.site {
    
		ip_hash;
		server 127.0.0.1:8081 weight=10;
	}
	# HTTPS server	
	server {
    
		listen 443 ssl;
		# To configure HTTPS The default access port for is 443.
		# If not configured here HTTPS The default access port of , It may cause Nginx Can't start .
		# If you use Nginx 1.15.0 And above , Please use listen 443 ssl Instead of listen 443 and ssl on.
		server_name www.cq.xxx.site; # Replace with domain name bound by certificate .
			ssl_certificate cert/5511216_www.cq.xxx.site.pem;  # Replace with the name of the uploaded certificate file .
			ssl_certificate_key cert/5511216_www.cq.xxx.site.key; # Need to put cert-file-name.key Replace with the name of the uploaded certificate key file .
			ssl_session_timeout 5m;
		ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
		# Represents the type of encryption suite used .
		ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Indicates the TLS The type of agreement .
		ssl_prefer_server_ciphers on;
	}
	server {
    
		listen 8080;
		server_name www.cq.xxx.site; # Replace with domain name bound by certificate .
		 # Point to deployment through configuration port websocket Project 
		location /api/my_webscoket  {
       
			 proxy_pass http://www.cq.xxx.site;      
			 proxy_http_version 1.1;    
			 proxy_set_header Upgrade $http_upgrade;    
			 proxy_set_header Connection "Upgrade";    
			 proxy_set_header X-real-ip $remote_addr;
			 proxy_set_header X-Forwarded-For $remote_addr;
		}
	}	
}

The first way

 Please add a picture description
 Please add a picture description

The second way

 Please add a picture description
 Please add a picture description

原网站

版权声明
本文为[I have an FC]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203021221198168.html