Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use PHP Socket.IO with Nginx/SSL or without SSL? #301

Open
wbsartori opened this issue Dec 5, 2023 · 3 comments
Open

How can I use PHP Socket.IO with Nginx/SSL or without SSL? #301

wbsartori opened this issue Dec 5, 2023 · 3 comments

Comments

@wbsartori
Copy link

Currently I use the socket passing the port and default settings of the SSL certificate. I would like to be able to use SSL directly with nginx so that it can manage the certificate for me. I found other issues talking about usage, but I wasn't successful in any of them.

My instance runs around this call:

    $io = new SocketIO($port, $sslContext);

My SSL configuration is in this format:

$sslContext = [
    'ssl' => [
       'local_cert' => '/etc/nginx/ssl/nginx.crt',
       'local_pk' => '/etc/nginx/ssl/nginx.key',
       'allow_self_signed' => true,
       'verify_peer' => false
    ]
];
@walkor
Copy link
Owner

walkor commented Dec 6, 2023

This is an example for nginx config

server {

  location /socket.io
  {
    proxy_pass http://127.0.0.1:2120;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Real-IP $remote_addr;
  }

}

Remember remove ssl config from phpsocket.io

@wbsartori
Copy link
Author

Does this usage format also work if I am using supervisor for my websocket service? Or would I need to do some additional configuration?

@AbdullahFaqeir
Copy link

Does this usage format also work if I am using supervisor for my websocket service? Or would I need to do some additional configuration?

If you want to use it with nginx/apache for SSL, it's pretty simple just like the above comment stated, nginx/apache will be handling the networking and SSL, it's called reverse proxy, and yes it can work with supervisor or forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants