Image

strapi

Deployment

2 min read
Last update: November 28, 2021

Deployment

module.exports = {
  apps : [
    {
      name: 'strapi-front',
      script: 'npm',
      cwd: '/var/www/strapi/strapi-front',
      args: 'start',
      env: {
        PORT: 3001
      },
    },
    {
      name: 'strapi-back',
      cwd: '/var/www/strapi/strapi-back',
      script: 'npm',
      args: 'start',
      env: {
        NODE_ENV: 'production',
        DATABASE_HOST: 'strapi-back.localhost', // database endpoint
        DATABASE_PORT: 5432,
        DATABASE_NAME: 'strapi', // DB name
        DATABASE_USERNAME: 'ewilan', // your username for psql
        DATABASE_PASSWORD: 'password', // your password for psql
      },
    },
  ]
};
server {
  # Listen HTTP
  listen 80;
  server_name strapi-back.localhost;

  # Proxy Config
  location / {
    proxy_pass http://strapi-back.localhost;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_pass_request_headers on;
  }
}

server {
  listen 80;
  server_name strapi.localhost;

  location / {
    include proxy_params;
    proxy_pass http://localhost:3001;
  }
}

Strapi

PostgreSQL

phpPgAdmin