Report this

What is the reason for this report?

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

Posted on February 26, 2020
tmw

By tmw

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!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

hello can you help me? I bought a droplet with strapi and I have error when I assign strapi to a subdomain when assigning my strapi to a subdomain admin.mydomain.com first the login image disappears, I get a 404 not found error and when entering admin.mydomain.com/admin I get an error 405 in / admin / init. Help please I am hazing on strapi and hosting it in production in the vps

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

This comment has been deleted

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.