跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[NGINX] 为什么 NGINX 使用自定义变量代理 ws 会异常?

发表于

之前一直用同样的方式连接后端服务, 是正常使用的。 如

location ^~/prod-api/ {
	    proxy_pass http://$api_host:$api_port;
	    ......
	}

异常情况:

连接 http://$api_host:8877/ws/ 就会异常

server {
        listen    443 ssl;
        set $api_host api;
        ..........

location  /ws/ {
            proxy_pass http://$api_host:8877/ws/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_connect_timeout 90s;
            proxy_send_timeout 120s;
            proxy_read_timeout 120s;
            send_timeout 120s;
        }
}

正常情况:

设置 http://api:8877/ws/ 正常

server {
        listen    443 ssl;
        set $api_host api;
        ..........

location  /ws/ {
            proxy_pass http://api:8877/ws/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_connect_timeout 90s;
            proxy_send_timeout 120s;
            proxy_read_timeout 120s;
            send_timeout 120s;
        }
}

在 nginx 容器内两种设置的抓包截图: https://imgur.com/a/XzyNFQ6

搞不清楚是什么原因导致这种情况,为什么不能这样配。想请教下大家

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.