1

I have an Apache-2.4 web server. It will execute PHP scripts if a client requests https://my.domain.com/script-name.php, and the output of the script shows up in the browser window. (Or it can be retrieved as AJAX data by Javascript.)

I would like to have a PHP script started this way, but have it talk to Javascript code in the browser which has done:

ws = new WebSocket( 'https://my.domain.com/script-name.php' );

Is this something that can be managed from within the PHP script, or must I use something like mod_proxy_wstunnel?

(I believe the underlying question is, what communication channels are available to a PHP script started by Apache? Does it have stdin/stdout as SSL sockets to/from the browser? Or is it receiving buffered data from Apache, and writing output data back to a buffer that Apache will eventually send to the client?)

Dave M.
  • 111
  • 3

1 Answers1

0

After fooling around with this some more, I realized that it's not possible for Apache to dup() some file descriptors and fork()/exec() to run a CGI script -- even if it worked that way on a non-SSL connection, it wouldn't work on SSL at least because the child process does not know the SSL key or connection state and cannot transmit or receive data directly to the browser. At least for SSL, Apache must forward the data back & forth.

As such, one of the mod_proxy solutions looks like the best bet here, too. I was able to get mod_proxy_wstunnel running with very little pain, so that's how I'm going to move forward with this project.

Dave M.
  • 111
  • 3