Ru

Connecting a domain to the CRYSTAL v1.0 project

28.02.2025

1. Connect to your domain, public IP address of the VM, in the settings of the domain operator.


2. Editing file – ‘crystal’, in the ‘sites-available’ folder.


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

3. Create a .env.prodDomain file in the frontend part and build the project for the domain.


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

4. Creating a .env.prodDomain file in the backend part of the project.


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.

The project is being tested in

BrowserStack

Share

Copy

BTC (Network BTC) - 1C2EWWeEXVhg93hJA9KovpkSd3Rn3BkcYm

Ethereum (Network ERC20) - 0x05037ecbd8bcd15631d780c95c3799861182e6b8

This website uses cookies. By clicking the 'Accept' button or continuing to use the website, you agree to the use of cookies.