Change the websocket URL /websocket

Hi all,

I’ve trying to find a way to change the websocket URL, like this:
From:
wss://{DOMAIN}/websocket
To:
wss://{DOMAIN}/websocket-admin

I have 2 meteor apps running on the same server & domain and would like to configure the Apache server to proxy URLs and their websockets to the appropriate app based on URL:

https://{DOMAIN}/login (app 1)
https://{DOMAIN}/admin (app 1)
wss://{DOMAIN}/websocket-admin (app 1)

https://{DOMAIN}/* (app 2)
wss://{DOMAIN}/websocket (app 2)

Any help would be appreciated.
Thanks

This might not match your overall url schema, but you can set one Meteor app to behind a path like /admin/* by setting the environment variable ROOT_URL to include /admin/.

Then Meteor sets that path as the path-prefix that’s used for the websocket url here:

Alternatively, you can use a local fork of ddp-server with the websocket-url of your choosing. You’ll also need to tell the client where to connect to. This is probably easiest done with the DDP_DEFAULT_CONNECTION_URL environment variable, but you’ll need to experiment a bit.

You can make local forks of core packages by copying the package folder from Meteor’s github into your /packages folder. Meteor always checks the packages/ folder first when deciding which version of a package to use

Thanks coagmano, I ended doing your first suggestion, appending /admin to the ROOT_URL. I had to mess up with the routing in the app but that seems to work fine now.

Thanks.

1 Like

Really small note on this - this doesn’t play nice with cordova (if that’s on your roadmap) - it hardcodes URL_PREFIX to “/”

1 Like

Thanks coagmano, I ended doing your first suggestion, appending /admin to the ROOT_URL. I had to mess up with the routing in the app but that seems to work fine now.

@zpatrick I know this is an old post but still. I tried appending /prefix to the ROOT_URL in env variable and in gateway I have configured the path /prefix/websocket. Yet it is failing. Am I missing something here??

@smacar the trailing / needs to be there (I forgot it in my comment), so it should be:

“ROOT_URL”: "https://domain.com/admin/ "

this way the websocket URL becomes:

wss://domain.com/admin/sockjs/250/qqph_4wi/websocket

Don’t forget your routes must have the /admin/ as well.

Thanks @zpatrick!! Is it possible to have like this
“ROOT_URL”: "https://domain.com/chat/admin/ "

I haven’t tried but I don’t see why not.

thanks great!! @zpatrick