How to connect to https on port 6001

Posted December 21, 2021 149 views

I’m currently trying to set up websockets with socketio and laravel-echo-server with Laravel as my API and React as my front-end. I have everything set up properly except I can’t access port 6001 over https.

Whenever I navigate to, which is where my websockets are hosted, I should get a response, but all I get is ERRCONNECTIONREFUSED or ERR_INVALID cert since it’s not allowing me to access port 6001 over https.

Is there a way to do this?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

What I would personally do is to use an Nginx server as a reverse proxy. That way you could install an SSL certificate via Nginx and then proxy the traffic to the Laravel echo server.

The proxy rule would look as follows:

location /ws/{

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forwarded-For $remote_addr;

Then rather than using https://your_domain:6001 in your frontend, you would use https://your_domain/ws which would internally proxy the traffic to the echo server.

Let me know how it goes!