Page MenuHomePhabricator
Paste P2025

Aphlict behind Apache
ActivePublic

Authored by lewellyn on Dec 12 2016, 3:40 AM.
As of Apache 2.4.5, `mod_proxy_wstunnel` is available, which (of course) requires `mod_proxy`: https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html
This module is part of recent Debian/Ubuntu packages, so you should be able to just `a2enmod proxy_wstunnel && systemctl restart apache2` before continuing. For other platforms, use whatever magic you normally would use to check if a module is available and enabled.
Your Apache configuration should already have this:
```
RewriteEngine on
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
```
Change it to this (and restart Apache):
```
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/ws/
RewriteCond %{QUERY_STRING} transport=websocket
RewriteRule /(.*) ws://localhost:22280/$1 [B,P,L]
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
```
As the doc at https://secure.phabricator.com/book/phabricator/article/notifications/#terminating-ssl-with-ngi says, configure your Phabricator accoridngly. Everything should now "just work". Close off port 22280 on your firewall, grab a beverage, and relax.

Event Timeline

lewellyn created this paste.Dec 12 2016, 3:40 AM
lewellyn mentioned this in Z1336: General Chat.
lewellyn edited the content of this paste. (Show Details)Dec 12 2016, 4:16 AM

The above did not work for me. The following did:

# Load PHP.
LoadModule php7_module lib/httpd/mod_php7.so
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

LoadModule rewrite_module lib/httpd/mod_rewrite.so

# Needed in order to proxy websockets connection for Phabricator's aphlict.
LoadModule proxy_module lib/httpd/mod_proxy.so
LoadModule proxy_wstunnel_module lib/httpd/mod_proxy_wstunnel.so

ProxyRequests Off

<VirtualHost *>
  ServerName phabricator.foo.bar

  DocumentRoot /opt/phacility/phabricator/webroot

  RewriteEngine on
  # Rewrite everything except for the websocket location.
  RewriteCond %{REQUEST_URI} !^/ws/
  RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]
    
  <Location "/ws/">
    ProxyPass        ws://127.0.0.1:22280/ws/ nocanon
  </Location>
  
  <Directory "/opt/phacility/phabricator/webroot">
    Require all granted
  </Directory>
  
</VirtualHost>