簡體   English   中英

ws protocol和apache mod_proxy_wstunnel配置:錯誤500

[英]ws protocol and apache mod_proxy_wstunnel configuration: error 500

嘗試通過我的Apache2服務器訪問ws:// localhost:8080 /時收到錯誤500。 該服務器運行OpenSuse Leap 42.1和Apache 2.4.16。

啟用了這些Apache2模塊:mod_proxy,mod_proxy_http,mod_proxy_wstunnel。

從本地網絡調用請求時,一切正常。 URL示例: http://<myhost-ip-address>/api/ws/<some-url> 它返回狀態101和響應: Upgrade: websocket 沒關系。

來自外部網絡的同類請求失敗。 URL示例: ws://www.mysite.com/api/ws/<some-url> 它返回錯誤500。

Apache訪問日志包含: GET /api/ws/<some-url> HTTP/1.1" 500 ...

Apache錯誤日志包含: [proxy:warn] AH01144: No protocol handler was valid for the URL /api/ws/<some-url>. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule. [proxy:warn] AH01144: No protocol handler was valid for the URL /api/ws/<some-url>. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

我的httpd.conf:

<VirtualHost *:80>
ServerName mysite.com
ServerAlias mysite.com
# Redirection for ws protocol
ProxyPreserveHost On
ProxyVia full
ProxyRequests OffHere
RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/api/ws/(.*)           [NC]
RewriteCond %{QUERY_STRING} transport=websocket     [NC]
RewriteRule /(.*)           ws://localhost:8080/$1  [P,L]
# Proxy pass
ProxyPass           /api/ws/            ws://localhost:8080/api/ws/
ProxyPassReverse    /api/ws/            ws://localhost:8080/api/ws/
# DocumentRoot
DocumentRoot /srv/www/vhosts/mysite.com
<Directory "/srv/www/vhosts/mysite.com">
    Options Indexes SymLinksIfOwnerMatch
    AllowOverride None
    ...
</Directory>
# URL as parameter
AllowEncodedSlashes NoDecode

我按照之前的StackOverflow回答(感謝): websocketsnode.jssocket-io ,但沒有運氣。

我的配置一定有問題。 有任何想法嗎 ?

編輯

正如adona9所建議的,這里是調試日志:

proxy_util.c(1784): AH00925: initializing worker ws://localhost:8080/api/ws/ shared
proxy_util.c(1826): AH00927: initializing worker ws://localhost:8080/api/ws/ local
...
mod_authz_core.c(809): AH01626: authorization result of Require user <user>: granted
mod_authz_core.c(809): AH01626: authorization result of <RequireAny>: granted
mod_charset_lite.c(219): AH01448: incomplete configuration: src unspecified, dst unspecified
mod_proxy.c(1159): AH01143: Running scheme ws handler (attempt 0)
mod_proxy_http.c(1944): AH01113: HTTP: declining URL ws://localhost:8080/api/ws/<some-url>
mod_proxy_wstunnel.c(341): AH02900: declining URL ws://localhost:8080/api/ws/<some-url>  (not WebSocket)
[proxy:warn] H01144: No protocol handler was valid for the URL /api/ws/<some-url>. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

有任何想法嗎 ?

所以我最終花了一天半的時間研究和閱讀深度apache2配置。 這就是我能夠解決這個問題的方法:

  • 使用forensic_logs和DumpIO在apache2端找到我的初始請求頭。

  • 記錄來自websocket客戶端的請求標頭。

驗證兩者都包含請求標頭中的升級標頭和連接類型websocket。 這些問題很可能是網絡過濾或刪除特定頭文件的結果。

我的問題是我使用的是AWS經典負載均衡器,它不支持websocket連接。

在閱讀其他論壇時,一些公司的防火牆也會從其連接中刪除特定的頭文件,因此它也可能就是這樣。

因此,如果您進行三重檢查以確保安裝了正確的模塊,那么很可能錯誤與網絡相關。

如果您有網絡圖,請檢查每個特定節點和網關,並驗證輸入和輸出請求標頭是否相同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM