nginx websocket 支持

Adding websocket support


Couhbase Lite iOS 1.0.3 introduces websocket support for the changes feed, but by default nginx will not upgrade it’s connection to Sync Gateway to support websockets. If an iOS client has websockets enabled for the _changes feed it will be unable to to pull replicate from a Sync Gateway behind an nginx reverse proxy. To enable websockets support, update the location block by adding the following two directives.

location / {
    .
    .  
    proxy_set_header        Upgrade $http_upgrade;
    proxy_set_header        Connection "upgrade";
    .
    .
}
	location / {
		index index.html index.htm;
	}

	location ~* \.(css|js)$ {
		gzip on;
		gzip_http_version 1.1;
		gzip_types text/css application/javascript application/x-javascript;
		gzip_buffers 4 8k;
		gzip_min_length 1000;
		gzip_comp_level 1;
		gzip_proxied off;
		gzip_disable "MSIE [1-6]\." "Mozilla/4";
		gzip_vary off;
		expires 30d;
	}

	location ~* \.(json|ttf|woff|otf|eot)$ {
		add_header 'Access-Control-Allow-Origin' '*';
		add_header 'Access-Control-Allow-Credentials' 'true';
		add_header 'Access-Control-Allow-Headers' 'Content-Type,Accept';
		add_header 'Access-Control-Allow-Method' 'GET, POST, OPTIONS, PUT, DELETE';
	}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注