最近在我的服務器中搭配了V2Ray+WebSocket+TLS+Nginx,成功倒是成功了,但是我的服務器在之前就用Apache+mediawiki搭建了一個百科,這兩者沖突了,
于是我先試著把V2Ray中的Nginx換成Apache,我首先參考了https://github.com/v2ray/v2ray-core/issues/747,關掉Nginx,然后在Apache組態檔中加入這段
<VirtualHost *:443>
ServerName subdomain.yourdomain.com
ServerAlias subdomain.yourdomain.com
##SSL Engine Switch:
#Enable/Disable SSL for this virtual host.
SSLEngine On
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:3579/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:3579/$1 [P,L]
##Proxy to port 3579
SSLProxyEngine On
Proxypass /ray http://127.0.0.1:3579
ProxyPassReverse /ray http://127.0.0.1:3579
SSLCertificateFile /etc/v2ray/v2ray.crt
SSLCertificateKeyFile /etc/v2ray/v2ray.key
</VirtualHost>
但是因為我的mediawiki中還有.htaccess檔案,結果上面的配置和.htaccess發生了沖突,
仔細檢查后,發現是上面那段配置中有一行錯誤,那就是
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:3579/$1 [P,L]
這里的意思應該是,非websocket請求則進入正常請求,結果這塊還是照樣進入了3579埠里,
我試圖修改匹配規則,但是修改半天還是沖突,干脆直接刪掉這兩行,結果居然就正常了,可能是直接跳過這塊的匹配,進.htaccess里面匹配去了
正確配置
<VirtualHost *:443>
ServerName subdomain.yourdomain.com
ServerAlias subdomain.yourdomain.com
##SSL Engine Switch:
#Enable/Disable SSL for this virtual host.
SSLEngine On
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:3579/$1 [P,L] # 注意該處的埠與v2ray的埠一致
# RewriteCond %{HTTP:Upgrade} !=websocket [NC]
# RewriteRule /(.*) http://localhost/$1 [P,L] # 自己的域名
##Proxy to port 3579
SSLProxyEngine On
Proxypass /ray http://127.0.0.1:3579
ProxyPassReverse /ray http://127.0.0.1:3579
SSLCertificateFile /etc/v2ray/v2ray.crt
SSLCertificateKeyFile /etc/v2ray/v2ray.key
</VirtualHost>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/259176.html
標籤:其他
下一篇:Noah Mt4跟單系統
