Ru

Connecting a domain to the CRYSTAL v1.0 project


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


2. Editing the file - 'crystal', in the 'sites-available' folder.


⚠️ Security note

In this manual and in other sections of the documentation, the sudo -i command is used to switch to superuser (root) mode. This is done to speed up the process and reduce commands.

In a production environment, running as root all the time is not recommended, as it violates the principle of least privilege and significantly reduces the security of the server.


Enable sudo:

sudo -i

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;
    # Limit the maximum size of files that can be uploaded via POST requests
	client_max_body_size 3M;
	location/
	{
		root /var/www/crystal/frontend/dist;
		try_files $uri $uri /index.html;
	}
	location /api/
	{
		proxy_pass http://127.0.0.1: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. Creating a .env.prodDomain file in the frontend part and building 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_API_BASE_URL=http://YourDomain/api > ./env/.env.prodDomain && npm run build:prod:domain

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


Enter the command:

cd /var/www/crystal/backend && nano ./env/.env.prodDomain

Next, enter the data below in the window that opens, and replace the sample text in the variable - 'CORS_ORIGIN', with your domain:

APP_MODE=prod (domain)
CORS_ORIGIN=http://YourDomain

After adding the code, press sequentially - 'ctrl + x', 'y', 'Enter'.


Next, you need to delete the old pm2 process and start a new one, to do this, enter the command:

pm2 kill && npm run start:prod:domain && 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.


CRYSTAL is tested on

BrowserStack

Share

Copy

USDT (TRON (TRC20)): TTvJdwtL3VAZKSHbYi8B2eQEQDxbHUD4Ka

POL (Polygon PoS): 0x97377684b9a589eca92e2c6c8430e6dcf2bae8c2

ETH (Base Mainnet): 0x97377684b9a589eca92e2c6c8430e6dcf2bae8c2

ETH (ERC20): 0x97377684b9a589eca92e2c6c8430e6dcf2bae8c2

BTC (BTC): 12GkhJZWrdn23PUerGerN7nSZXHwWGm59U

Similar posts

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