Update the Roxen Webserver to use Apache/Nginx
abdellahi-brahim opened this issue · comments
Hello!
I was wondering if it's possible to change the roxen webserver to Apache/Nginx and if it would require some breaking changes.
do you want to use apache/nginx to serve content created by roxen? or are you only serving static files? or do you want to get rid of roxen completely?
roxen is a web development framework and a webserver. if your instance only serves static files, it could be switched out, but otherwise it would be like replacing django or ruby on rails. neither can be done without rewriting all the code that makes up the website.
you can however use apache/nginx as a proxy to serve content generated by roxen.
Hello, I apologize for my delayed response.
Initially, my primary concern is to discern whether there's a clear distinction between the framework and the web server. If such a demarcation doesn't exist, I'd like insights on the best practices to decouple them. This includes identifying key areas of focus, understanding how to isolate those concerns, and ensuring the web server component can be extracted seamlessly.
To provide context, within Ruby on Rails, its modular design facilitated by the middleware pattern allows for the integration of diverse server libraries like Unicorn, Puma, and more.
the modular webserver in rails only allows you to replace the default webserver module with another webserver module also written in ruby. it would not allow you to replace it with nginx or apache.
to use nginx or apache with rails you still need one of the built in ruby webservers. https://stackoverflow.com/questions/579515/what-is-the-best-web-server-for-ruby-on-rails-application
the same is true for roxen. i believe the webserver equivalent in roxen/pike is sufficiently modular, it's just that there are no alternative webserver implementations written in pike that it could be replaced with, at least that i am aware of.
the configuration of apache or nginx to work with roxen should be similar to the configuration of apache/nginx for rails.
the difference is that for rails, using apache or nginx as a frontend server is generally recommended while for roxen it is possible but usually not needed unless multiple other services or multiple roxen instances need to be integrated.
Hey, thanks for clearing things up for me. I guess I had some things mixed up about how Rails' server modularity works. That link you shared really helped.
So, if I get this right, both Rails and Roxen have their quirks when it comes to swapping out web servers. They can play nice with different servers but only if they're in the same language family. And while you can pair them up with Apache or Nginx, you can't just kick them out and replace them entirely without redoing a lot of the site.
I get what you're saying about Rails usually having Apache or Nginx up front and Roxen not always needing that. Makes sense.
I'm gonna think over the whole setup and see if a proxy route is the way to go. If you've got any cool tips or links about setting up Roxen with Apache/Nginx, shoot them my way!
Thanks again for helping me out!
i am not familiar with apache, but for nginx the basic setup is to configure the site using proxy_pass: https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
here is a suitable example: https://stackoverflow.com/a/24908084
note that this example configures nginx to serve static files without roxen. but that is optional. unless your site suffers from a very high load, for roxen this is generally not needed, as it is sufficiently performant at serving static files. this is another key difference. serving static files with rails is not recommended, but serving them with roxen is just fine.
if all you need is to be able to run roxen alongside other sites, or even if it is just one site but running on a non-public port or server, then a simple setup like this may be enough: https://stackoverflow.com/a/24333362
but, as i said, if roxen is already running on a public server on a standard port, you don't need nginx at all. i would only set up nginx if there is a need to serve something outside of the roxen site.
you can't just kick them out and replace them entirely without redoing a lot of the site.
well, rather, you can't replace them without redoing the whole site. if you want to keep using rails in some form you must use one of the internal ruby webservers. the same is true for roxen. if you have dynamic content served by roxen, then you must keep using roxen with its internal webserver.