Running multiple domains on one NGINX server
In addition to westsloth.com domain we have now registered westsloth.fi domain for our planned business in Finland (mostly HW/SW consulting and financial and office management services).
As we are doing this part-time, we want to keep web hosting costs in control. Therefore we wanted to run the web pages of both domains on same server.
The original homepage of WestSloth Games (westsloth.com) has been running on single AWS Lightsail instance. In this solution, the monthly expenses are well-know in advance. But on the other hand server capacity is limited to some level. Anyways, the load for westsloth.com has not been too large for the Lightsail instance to handle it. So we thought we can easily run westsloth.fi on same server too.
Westsloth.com webserver is built using NGINX, Gunicorn and Django framework plus local MySQL database. Web page is built using Bootstrap front-end framework.
Adding another domain to NGINX setup was done by following these instructions on applicable part:
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
First step that was required to get two separate domains running on same server was to divide original document root (/var/www/html) to two separate document roots (/var/www/ws.com/html and /var/www/ws.fi/html).
Second step was to create new pages for westsloth.fi, and that was basically copying westsloth.com Bootstrap template and remove all unnecessary parts there. This was placed under ws.fi document root. Common static files like robots.txt were placed under ws.com document root.
In third step, original westsloth.com NGINX server block was duplicated (under nginx/sites-available). Westsloth.com part was left mostly unmodified, because only changes were related to static file locations. Westsloth.fi server block was configured to listen port 80 and westsloth.fi and www.westsloth.fi server names. Also, document root and index was defined here.
Last step was to enable server blocks by creating symbolic links of nginx/sites-available to nginx/sites-enabled directory. NGINX will read these during the startup.
After restarting NGINX everything seemed to be working as expected. So now we can concentrate on editing the content of both web pages!
-Jussi.
As we are doing this part-time, we want to keep web hosting costs in control. Therefore we wanted to run the web pages of both domains on same server.
The original homepage of WestSloth Games (westsloth.com) has been running on single AWS Lightsail instance. In this solution, the monthly expenses are well-know in advance. But on the other hand server capacity is limited to some level. Anyways, the load for westsloth.com has not been too large for the Lightsail instance to handle it. So we thought we can easily run westsloth.fi on same server too.
Westsloth.com webserver is built using NGINX, Gunicorn and Django framework plus local MySQL database. Web page is built using Bootstrap front-end framework.
Adding another domain to NGINX setup was done by following these instructions on applicable part:
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
First step that was required to get two separate domains running on same server was to divide original document root (/var/www/html) to two separate document roots (/var/www/ws.com/html and /var/www/ws.fi/html).
Second step was to create new pages for westsloth.fi, and that was basically copying westsloth.com Bootstrap template and remove all unnecessary parts there. This was placed under ws.fi document root. Common static files like robots.txt were placed under ws.com document root.
In third step, original westsloth.com NGINX server block was duplicated (under nginx/sites-available). Westsloth.com part was left mostly unmodified, because only changes were related to static file locations. Westsloth.fi server block was configured to listen port 80 and westsloth.fi and www.westsloth.fi server names. Also, document root and index was defined here.
Last step was to enable server blocks by creating symbolic links of nginx/sites-available to nginx/sites-enabled directory. NGINX will read these during the startup.
After restarting NGINX everything seemed to be working as expected. So now we can concentrate on editing the content of both web pages!
-Jussi.
Comments
Post a Comment