@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make paths and Aphlict instance names less ambiguous

Summary:
Fixes T10783 (what little of it remains). Ref T10697.

Aphlict currently uses request paths for two different things:

- multi-tenant instancing in the Phacility cluster (each instance gets its own namespace within an Aphlict server);
- some users configure nginx and apache to do proxying or SSL termination based on the path.

Currently, these can collide.

Put a "~" before the instance name to make it unambiguous. At some point we can possibly just use a GET parameter, but I think there was some reason I didn't do that originally and this sequence of changes is disruptive enough already.

Test Plan: Saw local Aphlict unambiguously recognize "local.phacility.com" as instance "local", with a "~"-style URI.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10697, T10783

Differential Revision: https://secure.phabricator.com/D15705

+22 -7
+1 -1
src/applications/notification/client/PhabricatorNotificationServerRef.php
··· 162 162 public function getWebsocketURI($to_path = null) { 163 163 $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); 164 164 if (strlen($instance)) { 165 - $to_path = $to_path.$instance.'/'; 165 + $to_path = $to_path.'~'.$instance.'/'; 166 166 } 167 167 168 168 $uri = $this->getURI($to_path);
+21 -6
support/aphlict/server/lib/AphlictClientServer.js
··· 52 52 response.end('HTTP/501 Use Websockets\n'); 53 53 }, 54 54 55 + _parseInstanceFromPath: function(path) { 56 + // If there's no "~" marker in the path, it's not an instance name. 57 + // Users sometimes configure nginx or Apache to proxy based on the 58 + // path. 59 + if (path.indexOf('~') === -1) { 60 + return 'default'; 61 + } 62 + 63 + var instance = path.split('~')[1]; 64 + 65 + // Remove any "/" characters. 66 + instance = instance.replace(/\//g, ''); 67 + if (!instance.length) { 68 + return 'default'; 69 + } 70 + 71 + return instance; 72 + }, 73 + 55 74 listen: function() { 56 75 var self = this; 57 76 var server = this._server.listen.apply(this._server, arguments); 58 77 var wss = new WebSocket.Server({server: server}); 59 78 60 79 wss.on('connection', function(ws) { 61 - var instance = url.parse(ws.upgradeReq.url).pathname; 62 - 63 - instance = instance.replace(/\//g, ''); 64 - if (!instance.length) { 65 - instance = 'default'; 66 - } 80 + var path = url.parse(ws.upgradeReq.url).pathname; 81 + var instance = self._parseInstanceFromPath(path); 67 82 68 83 var listener = self.getListenerList(instance).addListener(ws); 69 84