The server host of swoole can bind domain name, but it is not the effect of virtual host like apache or nginx. How to solve this problem?

new a server code in swoole is as follows:

$serv = new swoole_server("127.0.0.1", 9501);

now I want to create a HTTP server. I need to bind two domain names (www.a.com and www.b.com). After testing, the code is as follows

$serv = new swoole_server("www.a.com", 9501);
< H2 > question < / H2 >
  1. how can I implement a virtual host like apache httpd or nginx? That is, when multiple domain names are bound to the same ip, when accessed with different domain names, the content will be different?
Mar.03,2021

Nginx listens on multiple domain names and forwards them to swoole


document has a sentence:

swoole_http_server 's support for the Http protocol is incomplete and is recommended as an application server only. And add Nginx as a proxy at the front end

so, just add an agent at the front end.


Hello, how do you handle it now? Have you taken care of it? Am I asking this question now?

Menu