第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Nginx:WebSocket 通配符位置

Nginx:WebSocket 通配符位置

Go
慕勒3428872 2021-12-13 18:37:51
我在 Go 服務(wù)前使用了一個(gè) nginx 實(shí)例。我想將端口 80 上的任何內(nèi)容重定向到 https。[完畢]/* 處的所有(非 websocket)https 請(qǐng)求都應(yīng)轉(zhuǎn)到https://localhost:8443/ * [完成]/ws/* 的所有 websocket https 請(qǐng)求都應(yīng)該轉(zhuǎn)到https://localhost:8443/ws/ * [missing]我目前的配置:ssl_certificate                 ...ssl_certificate_key             ...ssl_ciphers                     ...ssl_prefer_server_ciphers       on;server {        listen         80;        location / {                return 301 https://$host$request_uri;        }}server {        listen          443 ssl;        server_name     www.mydomain.com mydomain.com;        add_header Strict-Transport-Security "max-age=31536000";        location /ws {   <--- This only works for /ws but not /ws/app1            proxy_pass http://localhost:8443/ws;            proxy_http_version 1.1;            proxy_set_header Host $http_host;            proxy_set_header Upgrade $http_upgrade;            proxy_set_header Connection "upgrade";        }        location / {    <--- Catches anything, even without wildcard ?!                proxy_pass http://localhost:8443;        }}server {        listen 443 ssl;        server_name *.mydomain.com;        return 444;}為什么這是必要的?好吧,據(jù)我所知,您必須明確設(shè)置升級(jí)標(biāo)頭,所以我想您必須指定另一個(gè)位置。理想情況下,我只使用一個(gè)位置,但隨后 websockets 被阻止(因?yàn)樯?jí)標(biāo)頭永遠(yuǎn)不會(huì)進(jìn)入 Go 服務(wù)......)我不是 nginx 專(zhuān)家,所以請(qǐng)耐心等待 =)。
查看完整描述

1 回答

?
藍(lán)山帝景

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊

https://www.digitalocean.com/community/tutorials/understanding-nginx-server-and-location-block-selection-algorithms查看文章

您沒(méi)有使用 any location_match,因此匹配是前綴匹配。

使用~作為位置匹配修飾符把它解釋為一個(gè)正則表達(dá)式。

該行location /ws應(yīng)該匹配每個(gè)以 開(kāi)頭的查詢(xún)/ws。


查看完整回答
反對(duì) 回復(fù) 2021-12-13
  • 1 回答
  • 0 關(guān)注
  • 179 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)