28.02.2025
Replace the IP address in the ‘crystal’ file, in line 4 – ‘server_name’, with your domain, as in the example below.
Enter the command:
nano /etc/nginx/sites-available/crystal
Example:
server {
listen 80;
listen [::]:80;
server_name YourDomain.com www.YourDomain.com;
location/
{
root /var/www/crystal/frontend/dist;
try_files $uri $uri /index.html;
}
location /api/
{
proxy_pass http://localhost:3000/;
proxy_hide_header X-Powered-By;
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;
}
}
Save changes – ‘ctrl + x’, ‘y’, ‘Enter’, then restart nginx with the command:
systemctl restart nginx
Change the sample text to the name of your domain and enter the command:
cd /var/www/crystal/frontend && echo VITE_BASE_URL=http://YourDomain/api > ./env/.env.prodDomain && pnpm buildProdDomain
Enter the command:
cd /var/www/crystal/backend && echo PRODUCTION_STATUS=true > ./env/.env.prodDomain
Next, you need to delete the old pm2 process and start a new one, to do this, enter the command:
pm2 kill && pnpm startProdDomain && pm2 save && pm2 startup && pm2 status
If the launch is successful, the process named – ‘prodDomain’ should have the status – ‘online’.
The site will be available at your domain address. The connection should be via the protocol – ‘http’, check this in the address bar of the browser. The site will not open if the connection is established via the protocol – ‘https’.
If you have already installed an SSL certificate on your domain, the browser may automatically redirect the request from the ‘http’ protocol to ‘https’.
To remove the redirect, enter the following line in the address bar of the Chrome browser:
chrome://net-internals/#hsts
Then in the window that opens, in the field – ‘Delete domain security policies’, enter your domain and click the button – ‘Delete’.
Next, you can connect a free Let’s Encrypt SSL certificate to the domain, with automatic renewal, for this use this instructions.
Share
Comment on