2017-10-30 4 views
0
location /x/ { 

    limit_conn x 500; 

    add_header Access-Control-Allow-Origin *; 

    allow all; 

    proxy_http_version 1.1; 

    proxy_set_header Upgrade $http_upgrade; 

    proxy_set_header Connection $http_connection; 

    chunked_transfer_encoding off; 

    proxy_buffering off; 

    proxy_cache off; 

    proxy_read_timeout 2073600; 

    if ($http_upgrade = websocket) { 

    proxy_pass  http://x; 

    } 
    if ($http_upgrade != websocket) { 

    proxy_pass  http://y; 

    } 

} 

Hier will ich „websocket“ zu Groß- und Kleinschreibung (ignorieren Fall) .Wie machen kann ich machen? Ich habe einige Dinge selbst ausprobiert. Wie:Wie funktioniert die Bedingung innerhalb eines Standortblocks in nginx conf?

1. 

if ($http_upgrade = ~*websocket) { 

    proxy_pass  http://x; 
    } 

if ($http_upgrade != ~*websocket) { 

    proxy_pass  http://y; 
    } 

2. 

if ($http_upgrade = "(?i) websocket") { 

proxy_pass  http://x; 
    } 

if ($http_upgrade != "(?i) websocket") { 

proxy_pass  http://y; 
    } 

Aber beide Fälle, diese funktionieren nicht.

Antwort

0

Bitte versuchen Sie es wie diese:

if ($http_upgrade == "websocket") 
{ 
    proxy_pass  http://x; 
} 
if ($http_upgrade != "websocket") 
{ 
    proxy_pass  http://y; 
} 

ODER

if ($http_upgrade == "websocket") 
{ 
    proxy_pass  http://x; 
} 
else 
{ 
    proxy_pass  http://y; 
} 
Verwandte Themen