Strapi Deployment

System Information
  • Strapi Version: 3.5.4
  • Operating System: Linux 8.11
  • Database: default…
  • Node Version: 14.16.0
  • NPM Version: 7.8.0
  • Yarn Version: 1.22.10

Hi,
I’m quite new to Strapi, and I’m currently trying to deploy on a managed cloud server on Infomaniak.

So far, I’m able to follow the documentation process until the server startup NODE_ENV=production npm start.
I generated the admin with NODE_ENV=production yarn build --clean
Strapi server does start, and the url of the admin panel is displayed in the CLI.

However, the url sends a 404 error (api . mydomain . com/admin)
And the api root sends a 403 error (api . mydomain . com)

This 403 error is usually displayed by default on managed Infomaniak hosts, when the resource does not have any index file.

Therefore, I’m wondering if my configuration is correct.
Which folder is the (sub)domain address supposed to target? I targeted the root folder of the Strapi project…
I also tried the public and the build folders without success. build shows a blank html page.

Those aspects are not really covered in the documentation, if I’m not wrong.

Could you help me to set Strapi up on this host?
Thanks


2 Likes

Did you install/configure one of the proxy options from the documentation?

Without those, your domains would be (assuming you are using the default 1337 port)

The proxy layers are needed for SSL and to bind on ports below 1024 (as you shouldn’t be running a node process as root). HTTP uses port 80, HTTPS uses port 443.

1 Like

Thanks for your help.

I opened the 1337 port in the firewall (TCP entering and exiting).

I’m using an Apache server (2.4.46), but I’m not so sure if I have enough freedom to configure proxy on a managed hosting.
I can add environment variables though…

Also, I can’t access Strapi either with explicit port (api.mydomain.com:1337) : page not loading, timeout.

Here is my server.js

module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),
  url: env('PUBLIC_URL', 'https://api.example.com'),
  admin: {
    auth: {
      secret: env('ADMIN_JWT_SECRET', '[...]'),
    },
  },
});

And .env:

HOST=0.0.0.0
PORT=1337
PUBLIC_URL=[the API real url] 

Shall I use another hosting solution? If so, are there any recommandation?

That is not really an environment we support as managed hosting can have a lot of restrictions for running services.

Entirely up to you and what you are familiar with or prefer. (Cost also) I don’t think there is a single major cloud platform I haven’t seen Strapi deployed on; AWS, GCloud (Compute and GAE), Azure, DigitalOcean, Vultr, Linode, OVH, IBM Cloud, ect.

I would say in most cases hosting that gives you a “CPanel, Plesk, insert some odd Server GUI” is not something that is geared towards applications like Strapi. We are an extremely code focused headless CMS and not as database dynamic like some of the older monolithic CMSes. There will almost certainly be a need to touch the CLI/Terminal at some point and being familiar with that is certainly a good skill to have.

I understand… It’s not so obvious to get started with private/virtual hosting though.

I’m turning towards the docker container, through Jelastic.
So far I’m able to build the Strapi admin and start it. I’m now looking for a way to get access to the admin through Http.
But that’s another issue…

Thanks :slight_smile:

Edit:
By the way, it would be nice to update the recommended requirements of the documentation, for newbies like me…
Indeed, my initial hosting did meet these requirements, with Node, NPM, build-essentials…
But not the ability to configure a proxy I suppose.
Therefore, I invested quite some time with Strapi on localhost, guessing it would be compatible with my hosting service…

1 Like

I finally managed to make Strapi work on a managed hosting :star_struck:

Here is my setup:
.env :

HOST=0.0.0.0
PORT=1337
PUBLIC_URL=https://my.domain.com

.htaccess :

RewriteEngine On
RewriteRule ^$ http://localhost:1337/ [P]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://localhost:1337/$1 [P]
2 Likes

Hello @Damien i will be very enjoy to talk with you because i’m trying to deploy my strapi app on infomaniak server but i dont know the best choice is. Managed server or jelastic ? and deploy juste once or by github/gitlab merge request… if you can help me to do it it will be the paradise for me because its hard to find some informations about infomaniak deployment tricks. thanks in advance

Hi @Damien, is the .htaccess placed in your project root?

Damien, can you help with some details. I have dev version running on local machine and a VPS with npm installed.
How should I deploy on Managed Server via cPanel? Should I build first and put files on server Or should build on Server itself?

Hi everyone.

I would like to know if anyone is having problems with the Knex module when they do some kind of deployment.

I’m trying to deploy in Render and I’ve been with this error for days:

Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

I am using Strapi v.4 and the error started when I made a new deploy in which I had only modified some models of the database.
So far, the only thing I have found has been this thread:

Basically it is to change the versions of JSON packages and if you do, you get something similar to a Strapi version 3.

It seems that there may be some version compatibility issues with knex/pg/node.
Any suggestion? Thanks

I am running in the same issue. I’m hosting on www.render.com.

My node Strapi service is running on 2 CPU and 4GB RAM.

My Postgres database is running on 2 CPU and 4GB RAM.

I’m using the following settings in /config/env/production/database.js

const { parse } = require("pg-connection-string");

module.exports = ({ env }) => {
  const { host, port, database, user, password } = parse(env("DATABASE_URL"));

  return {
    connection: {
      client: "postgres",
      connection: {
        host,
        port,
        database,
        user,
        password,
        ssl: {
          rejectUnauthorized: false,
        },
      },
      debug: true,
      pool: {
        min: 0,
        max: 10,
        idleTimeoutMillis: 30000000,
        createTimeoutMillis: 30000000,
        acquireTimeoutMillis: 30000000,
        propagateCreateError: false,
      },
    },
  };
};

Hello I’m interested in having feedback on your experience deploying on Infomaniak. Was it working well?
What was finally the setup you choosed and for which cost? Indeed I’m looking for a way to host a small personal project (with very low usage) and look for cheap hosting for it.

Thank you