21
Апр

Mixed Content при обращении к WebSocket

Ситуация, когда у вас поднят WebSocket сервер и вы пытаетесь получить к нему доступ, например из Vue.

[bash title=»код»]self.ws = new WebSocket(‘wss://hd.zp.ua:9991’); [/bash]

Вы скорее всего получите ошибку Mixed Content

Mixed Content: The page at ‘https://hd.zp.ua/admin/service’ was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ‘ws://hd.zp.ua:9991/events’. This request has been blocked; this endpoint must be available over WSS.

[bash title=»код»]use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;

// Iniciando conexão
$server = IoServer::factory(
new HttpServer(
new WsServer(
new SimpleChat()
)
),
9991
);
$server->run();[/bash]

Можно спроксировать запрос к WebSocket серверу через nginx:

[bash title=»код»]location /services/myservice {
# switch off logging
access_log off;

# redirect all HTTP traffic to localhost
proxy_pass http://localhost:9991;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

# Path rewriting
rewrite /services/myservice/(.*) /$1 break;
proxy_redirect off;

# timeout extension, possibly keep this short if using a ping strategy
proxy_read_timeout 99999s;
}[/bash]

[bash title=»код»]self.ws = new WebSocket(‘wss://hd.zp.ua/services/myservice’);[/bash]

Обратите внимание. Порт 9991 (или тот который вы будете использовать), нельзя открывать наружу.

Обратная связь

    The average number of adverse effects was 3. T max is 23 minutes in females and 32 minutes in males. What other drugs will affect doxercalciferol Viagra natural sin receta. Archived from the original on 2009-08-14.

    Talk to your doctor before using this form of cefadroxil if you have diabetes. What should I tell my healthcare team before starting CABLIVI? There is no FDA guidance on the use of Tetracycline (oral) with respect to specific gender populations https://www.apotheke-rezeptfreie.com/. Opper K, Uder S, Song K Development of Heterogeneous and Homogeneous Platforms for Rapid Analysis of DNA-Protein Interactions.

    Contact Us