Question

Can I host a Strapi CMS and the front-end application on the same droplet?

Posted February 26, 2020 1.7k views
DigitalOceanCMS

Is it possible to host a Strapi CMS and the front-end application (also running on NodeJS) that consumes the Strapi API on the same droplet? Is it possible to use sub-domains to direct tot he 2 apps? e.g. admin.domain.com for Strapi and domain.com just loads the public app?

I’m really a novice when it comes to hosting/deployment so appreciate any advice.

Thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hello,

Yes, this would not be a problem. What you would need keep in mind is:

  • Make sure that the Strapi and the Node.js applications are running on different ports, for example, start Strapi on port 1337 as suggested in the documentation.

  • You can take a look at the steps on how to install Strapi on a DigitalOcean Droplet here:

https://strapi.io/documentation/3.0.0-alpha.x/guides/deployment.html#digital-ocean

  • Then you can start Node.js on port 8080 for example.

  • Finally install Nginx and set it up as a reverse proxy for your Node.js application:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

  • Also if needed you can create a second Nginx server block for your Strapi app and set the server_name to your admin.domain.com subdomain name as you mentioned. The Nginx proxy rules that you would need to add for the Strapi application would be a bit different to the Node.js ones, you can use the following:
proxy_pass http://localhost:1337;  
proxy_http_version 1.1;  
proxy_set_header Upgrade $http_upgrade;  
proxy_set_header Connection 'upgrade';  
proxy_set_header Host $host;  
proxy_cache_bypass $http_upgrade; 

Hope that this helps!
Let me know if you have any questions.
Regards,
Bobby

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.
Submit an Answer