I'm building a SvelteKit app that isn't completely prerenderable and thus cannot be hosted with static-adapter
. Do I have any options for hosting it with Apache? I would like to avoid running a reverse-proxy that that redirects some paths to Apache and some to e.g. NodeJS.
Asked
Active
Viewed 2,379 times
2

Anna
- 2,645
- 5
- 25
- 34
-
Not sure I understand your question. For a non-static app, you'll need a Node backend (and likely some kind of framework like Express/Koa/Fastify), so you *will* have to use a reverse proxy in your Apache config to redirect requests to your Node server. A reverse proxy sounds more complicated to set up than it really is, though, and there is plenty of readily available information online to guide you, including here on SO. For instance: https://stackoverflow.com/questions/32605232/how-to-deploy-nodejs-app-on-php-apache-server/32607473#32607473. – Thomas Hennes Nov 26 '21 at 09:15
-
I assumed from your question that you are planning to host the app on a server you own or have access to. You could also choose to use a 3rd party service like Vercel or Netlify, in which case you'd use the appropriate adapter instead. – Thomas Hennes Nov 26 '21 at 09:18
-
Thank you Thomas. Yes, I already have a server hosting a couple semi-popular websites with Apache. That's the reason I don't want to complicate the setup by moving Apache from port 80. so a solution I'll try before that is simply renting a second server. I understand then that it is not possible to host a non-prerenderable SvelteKit app via Apache (without changing Apache port)? – Anna Nov 26 '21 at 09:21
-
No no, it *is* possible, but not with Apache *alone*. But believe me, the reverse proxy configuration is fairly trivial and straightforward once you get into it. The virtual host block in the answer I linked is a very typical setup for reverse proxy and is only a few lines long. No need to mess with the Apache port. Just setup a VHost with the domain name you want to use, and redirect the root to your Node process (which will typically be running on `localhost:XXXX`) and that's it. – Thomas Hennes Nov 26 '21 at 09:23
-
@ThomasHennes Aha, I read the link you posted. I was under the impression that a reverse-proxy solution would use e.g. nginx on port 80 which would then forward requests to either Apache or the Node backend. But now I understand that Apache can remain on port 80 and itself forward some requests to the Node backend? – Anna Nov 26 '21 at 09:26
-
Exactly! :) You got it already! – Thomas Hennes Nov 26 '21 at 09:28