In this part we will see how to configure Soketi and how to install SSL certificate.
Step 1: Change the default config of Soketi
This step is optional
As we know the default credentials of Soketi is:
- App ID: app-id
- App Key: app-key
- Secret: app-secret
To change these credentials first we need to create a folder.
sudo mkdir /etc/my_soketi Enter the folder (change the folder/file name as you want)
cd /etc/my_soketi Create a json file config.json
sudo vim config.json Contains:
{ "debug": true, "port": 6001, "appManager.array.apps": [ { "id": "your-new-id", "key": "your-new-key", "secret": "your-new-secret" } ] } If you want to see the logs of Soketi make "debug": true,, and if you do not care just make false.
Now we need to turn off our Soketi server running by pm2:
pm2 stop soketi If you need to know the name run
pm2 statusand take the name of service
And now rerun the Soketi server by:
pm2 start soketi -- start --config=/etc/my_soketi/config.json Now change the credentials in Laravel project in .env file to the new one.
Step 2: Link IP With Domain
Go to the domain provider and make a new subdomain(domain) and create a new record then put your public IP.
After you make sure that the subdomain is run your Soketi server by returning OK when you open the domain, go to Nginx config file and update the server_name to your subdomain.
sudo vim /etc/nginx/nginx.conf server_name your_subodmain; Now restart the Nginx
sudo systemctl restart nginx.service Step 3: Install SSL
I will use let's encrypt to install SSL on my domain.
To install SSL run these three commands:
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm sudo yum-config-manager --enable epel sudo yum install certbot python2-certbot-nginx -y Then run:
sudo certbot --nginx Some questions will show:
1. type your email: XXXXXX@gmail.com 2. (Y)es/(N)o: y 3. (Y)es/(N)o: y 4.
blank to select all options shown (Enter 'c' to cancel): 1 Now you will get your SSL on domain once you visit it.
To renew the Certificate automatically you need to set a cronjob via crontab. The commands are given below.
sudo crontab -e put this line into the file:
0 3 * * * sudo certbot renew >/dev/null 2>&1 Step 4: Configure The Laravel App With SSL.
in .env:
PUSHER_APP_KEY=key PUSHER_APP_ID=id PUSHER_APP_SECRET=secret PUSHER_HOST="sub.app.co" PUSHER_PORT=443 PUSHER_SCHEME=https VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" VITE_PUSHER_HOST="${PUSHER_HOST}" VITE_PUSHER_PORT="${PUSHER_PORT}" VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" In bootstrap.js:
window.Echo = new Echo({ broadcaster: "pusher", key: import.meta.env.VITE_PUSHER_APP_KEY, forceTLS: false, encrypted: import.meta.env.VITE_PUSHER_ENCRYPTED === "true", wsHost: import.meta.env.VITE_PUSHER_HOST, wsPort: import.meta.env.VITE_PUSHER_PORT, wssPort: import.meta.env.VITE_PUSHER_PORT, disableStats: true, enabledTransports: ["ws", "wss"], }); That's it 🚀
I would thank @Sinnbeck on laracast.com that helping me to finish this series ❤️
Top comments (0)