Use mod_proxy_http for websocket upgrade

mod_proxy_wstunnel is deprecated as of httpd 2.4.47. It also uses more resources since it relies on mod_rewrite.

See https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#protoupgrade.
pull/819/head
nisbet-hubbard 2023-07-12 18:18:48 +08:00 committed by GitHub
parent 8ba4b72b37
commit 76667ffcf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 14 deletions

View File

@ -649,8 +649,8 @@ or the root domain:
<VirtualHost *:80> <VirtualHost *:80>
ServerName ntfy.sh ServerName ntfy.sh
# Proxy connections to ntfy (requires "a2enmod proxy") # Proxy connections to ntfy (requires "a2enmod proxy proxy_http")
ProxyPass / http://127.0.0.1:2586/ ProxyPass / http://127.0.0.1:2586/ upgrade=websocket
ProxyPassReverse / http://127.0.0.1:2586/ ProxyPassReverse / http://127.0.0.1:2586/
SetEnv proxy-nokeepalive 1 SetEnv proxy-nokeepalive 1
@ -662,11 +662,6 @@ or the root domain:
# Enable mod_rewrite (requires "a2enmod rewrite") # Enable mod_rewrite (requires "a2enmod rewrite")
RewriteEngine on RewriteEngine on
# WebSockets support (requires "a2enmod rewrite proxy_wstunnel")
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L]
# Redirect HTTP to HTTPS, but only for GET topic addresses, since we want # Redirect HTTP to HTTPS, but only for GET topic addresses, since we want
# it to work with curl without the annoying https:// prefix # it to work with curl without the annoying https:// prefix
RewriteCond %{REQUEST_METHOD} GET RewriteCond %{REQUEST_METHOD} GET
@ -681,8 +676,8 @@ or the root domain:
SSLCertificateKeyFile /etc/letsencrypt/live/ntfy.sh/privkey.pem SSLCertificateKeyFile /etc/letsencrypt/live/ntfy.sh/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf Include /etc/letsencrypt/options-ssl-apache.conf
# Proxy connections to ntfy (requires "a2enmod proxy") # Proxy connections to ntfy (requires "a2enmod proxy proxy_http")
ProxyPass / http://127.0.0.1:2586/ ProxyPass / http://127.0.0.1:2586/ upgrade=websocket
ProxyPassReverse / http://127.0.0.1:2586/ ProxyPassReverse / http://127.0.0.1:2586/
SetEnv proxy-nokeepalive 1 SetEnv proxy-nokeepalive 1
@ -694,10 +689,6 @@ or the root domain:
# Enable mod_rewrite (requires "a2enmod rewrite") # Enable mod_rewrite (requires "a2enmod rewrite")
RewriteEngine on RewriteEngine on
# WebSockets support (requires "a2enmod rewrite proxy_wstunnel")
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L]
</VirtualHost> </VirtualHost>
``` ```