1

I am using a Ruby on Rails application and currently have it configured to run using Apache and a VirtualHost. However, the virtualhost configuration at the moment is only configured to support my domain. I am looking for a way to be able to dynamically add a ServerAlias so that my application can respond to multiple custom domains. I understand that I can just simply add ServerAlias to my VirtualHost configuration, but this requires me to have reload Apache configuration, which negatively affects the site as there is a 5-10 second pause, if not longer sometimes.

Can I just simply maintain a list of domains in a text file and have Apache point all of those to the same directory as the original virtualhost?

1
  • How many virtual hosts do you have? Can you just make that the default vhost? – jordanm Apr 23 '20 at 20:17
0

Having just the domain names in a file will not work. But you can have such a file, prepend ServerAlias to each entry and include that file from the other configuration file.

Independent of that: Reloading should not take that much time. I suggest you examine that problem.

If for whatever reasons your Apache cannot reload quickly then it may be a good idea to put something in front of that Apache what can: HAproxy or nginx. Then you have one static configuration in Apache for those identical domains (running on a separate port) and the proxy decides to which Apache config (port) a request is sent.

3
  • Thanks. The reload command is pretty quick, but the website itself takes about a good 20 seconds to actually refresh. Might need to dig into what could be causing it -- my assumption is something to do with assets and precompiling, but I could be wrong. With regards to being able to create a simple text file that has ServerAlias <domainName> and include the original file, any additional information on that by chance? – LewlSauce Apr 23 '20 at 20:44
  • 1
    @LewlSauce Includes are really trivial: httpd.apache.org/docs/2.4/en/mod/core.html#include But the list file would not include the config file but the other way round. You replace the ServerAlias line(s) with the Include statement. – Hauke Laging Apr 23 '20 at 20:50
  • Gotcha. Thanks a lot! Going to give this a shot now! – LewlSauce Apr 23 '20 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.