Multinenancy via URL - `:path` option under `:url` configuration in `Phoenix.Endpoint` not working?

Sorry if this question is really basic. I have a server for which it’s inconvenient for me to configure the DNS records. However I need to host several phoenix apps on it. Therefore I’d like to do it in such a way: www.myserver.com/appA, www.myserver.com/appB.

I am able to configure Nginx/HAProxy to proxy traffic to those URLs to different ports of the server, and use the URL rewrite rule to strip the /appA part. Apparently the base URL of the app needs to have /appA appended, otherwise the requests for static assets will not be rewritten correctly (i.e. the links need to be www.myserver.com/appA/js/app-hash.js instead of just www.myserver.com/js/app-hash.js)

The :path option under :url in Phoeix.Endpoint is supposed to help with this scenario. However, changing it to /appA seems to have no effect. The links to the static assets still seem to be www.myserver.com/js/app-hash.js?

I’m not sure what I’m doing wrong here. After changing the option, I ran through the following:

$ mix deps.get --only prod
$ MIX_ENV=prod mix compile
$ brunch build --production
$ mix phx.digest

so I thought the links should have been updated.

1 Like

No idea what I did wrong but I tried to compile the assets the second time and it added the path correctly. I don’t seem to be able to delete this post now.

2 Likes

It’s good to leave these posts anyway so it could potentially help someone else in the future. :slight_smile:

1 Like

“Just try again, it will work for sure”. :smiley:

But yes, posts should remain for historical value, I fully agree.

1 Like

Well with brunch ‘run it again’ is a common fix. ^.^;

That’s one plus about moving to webpack (though I still prefer and use raw npm scripts myself) in the next phoenix version. :slight_smile:

Yeah I guess if there’s any value it is in using the :path option to deal with multitenancy in the first place, which I didn’t know at first and couldn’t find search results about.